Devops and Git Int Ques
Devops and Git Int Ques
The Git rebase command enables developers to incorporate changes from one branch into another, while the Git
merge command allows for the merging of branches in Git.
Both Git rebase and merge serve the purpose of integrating changes from one branch to another. However, they
differ in their usage. Git rebase is used to move a feature branch into a master branch, whereas Git merge adds a
new commit while preserving the existing history.
When working individually or in a small team, it is recommended to use rebase. On the other hand, when
collaborating with a large team, it is advisable to use merge.
When Git encounters a merge conflict, it means that it cannot automatically reconcile differences between two
commits in the code. Automatic merging is possible when the changes occur on different lines or branches. To resolve
conflicts in Git, follow these steps:
The most straightforward method is to open the conflicted file and manually make the necessary adjustments.
After modifying the file, use the "git add" command to stage the merged content.
Finally, create a new commit by using the "git commit" command.
Git will generate a new merge commit to finalize the merge process.
3) How will you find a list of files that has been modified in a particular commit?
The command to get a list of files that has been changed in a particular commit is:
git diff-tree –r {commit hash}
This command enables you to pick up commits from a branch within a repository and apply it to another branch. This
command is useful to undo changes when any commit is accidentally made to the wrong branch. Then, you can
switch to the correct branch and use this command to git cherry-pick the commit.
The Git pull command retrieves and incorporates new changes or commits from a specific branch in your
central repository, updating the corresponding branch in your local repository. Essentially, Git pull combines the
functionalities of git fetch and git merge.
Similarly, Git fetch serves the same purpose but operates in a slightly distinct manner. When you execute a git
fetch, it retrieves all the recent commits from the designated branch and stores them in a new branch within
your local repository. To reflect these changes in your target branch, you need to follow git fetch with a git
merge.
It allows the user to switch between the branches to keep the current work in sync without disturbing master branches
and other developer’s work as per their requirements.
1) Feature branching - A feature branch model keeps all of the changes for a particular feature inside of a branch.
When the feature is fully tested and validated by automated tests, the branch is then merged into master.
2) Task branching - In this branch, each task is implemented on its own branch with the task key included in the
branch name. It is easy to see which code implements which task, just look for the task key in the branch name.
3) Release branching - Once the develop branch has acquired enough features for a release, you can clone that
branch to form a Release branch.Creating this branch starts the next release cycle, so no new features can be added
after this point, only bug fixes, documentation generation,and other release-oriented tasks should go in this branch.
Once it is ready to ship, the release gets merged into master and tagged with a version number.
Although DevOps shares some similarities with the Agile methodology, which is one of the most popular SDLC
methodologies, both are fundamentally different approaches to software development. Following are the various
fundamental differences between the two:
a) Agile Approach - The agile approach is only meant for development in Agile while the Devops approach is meant
for both development and operations in DevOps.
b) Practices and Processes - While agile involves practices such as Agile Scrum and Agile Kanban, DevOps involves
processes such as CD (Continuous Delivery), CI (Continuous Integration), and CT (Continuous Testing).
c) Priority - Agile prioritizes timeliness whereas, DevOps gives equal priority to timeliness and quality.
d) Release Cycles - DevOps offers smaller release cycles with immediate feedback while Agile offers only smaller
release cycles without immediate feedback.
e) Feedback Source - Agile relies on feedback from customers while feedback from self (monitoring tools) is involved
in DevOps.
f) Scope of Work – For Agile, the scope of work is agility only but for DevOps, it is agility and the need for automation.
Organizations these days are trying to transport small features to customers via a series of release trains instead of
releasing big feature sets. There are several benefits of doing so, including better software quality and quick customer
feedback.All such benefits lead to a higher level of customer satisfaction, which is the most important goal for any
product development project. To do so, companies need to:
Increase deployment frequency
Lessen lead time between fixes
Lower failure rate of new releases
In case of new release crashing, have a faster mean time to recovery
DevOps helps in fulfilling all these requirements and thus, achieving seamless software delivery. Full-fledged
organizations like Amazon,
Etsy, and Google have adopted DevOps methodology resulting in achieving performance levels that were
previously uncharted.
With the adoption of DevOps methodology, organizations are able to accomplish tens to thousands of deployments in
a single day. Moreover, doing so while offering first-rate reliability, security, and stability.
When a DevOps pattern commonly adopted by other organizations doesn’t work in a specific context and still the
organization continues using it, it leads to the adoption of an anti-pattern. In other words, anti-patterns are myths
about DevOps. Some of the notable anti-patterns are:
The traditional software development lifecycle when graphed on a paper has two sides, left and right. While the left
side of the graph includes design and development, the right side includes production staging, stress testing, and user
acceptance.To shift left in DevOps simply means the necessity of taking as many tasks on the right i.e. that typically
happens toward the end of the application development process and incorporate them into earlier stages of a
DevOps methodology.
There are several ways of accomplishing a shit left in DevOps, most notably:
Create production-ready artifacts at the end of every Agile sprint
Incorporating static code analysis routines in every build
The level of doing the DevOps the right way is directly dependent on the degree of shifting left as much as
possible.
Removal of the possibility of human error from the CD equation (Core benefit)
As tasks become more predictable and repeatable, it is easy to identify and correct when something goes
wrong. Hence, it results in producing more reliable and robust systems
Removes bottlenecks from the CI pipeline. It results in increased deployment frequency and decreased number
of failed deployments. Both of them are important DevOps KPIs
12) Please explain the core operations of DevOps in terms of development and infrastructure.
Application development – Developing a product that is able to meet all customer requirements and offers a
remarkable level of quality
Code coverage – Measurement of the total number of blocks or lines or arcs of the code executed while the
automated tests are running
Code developing – Prepare the code base required for the product development
Configuration – Allowing the product to be used in an optimum way
Deployment – Installing the software to be used by the end-user
Orchestration – Arrangement of several automated tasks
Packaging – Activities involved when the release is ready for deployment
Provisioning – Ensuring that the infrastructure changes arrive just-in-time with the code that requires it
Unit testing – Meant for testing individual units or components
13) How do you revert a commit that has already been pushed and made public?
One or more commits can be reverted through the use of git revert. This command, in essence, creates a new commit
with patches that cancel out the changes introduced in specific commits. In case the commit that needs to be
reverted has already been published or changing the repository history is not an option, git revert can be used to
revert commits. Running the following command will revert the last two commits:
14) How do you setup a script to run every time a repository receives new commits through push?
To configure a script to run every time a repository receives new commits through push, one needs to define either a
pre-receive, update, or a post-receive hook depending on when exactly the script needs to be triggered.
Pre-receive hook in the destination repository is invoked when commits are pushed to it. Any script bound to this hook
will be executed before any references are updated. This is a useful hook to run scripts that help enforce development
policies.
Update hook works in a similar manner to pre-receive hook, and is also triggered before any updates are actually
made. However, the update hook is called once for every commit that has been pushed to the destination repository.
Finally, post-receive hook in the repository is invoked after the updates have been accepted into the destination
repository. This is an ideal place to configure simple deployment scripts, invoke some continuous integration systems,
dispatch notification emails to repository maintainers, etc.
Hooks are local to every Git repository and are not versioned. Scripts can either be created within the hooks directory
inside the “.git” directory, or they can be created elsewhere and links to those scripts can be placed within the
directory.
15) One of your teammates accidentally deleted a branch, and has already pushed the changes to the central git
repo. There are no other git repos, and none of your other teammates had a local copy. How would you recover this
branch?
Check out the latest commit to this branch in the reflog, and then check it out as a new branch.
As a merge commit belongs to a different branch, it has two parents and two changesets.
For example, if you have merge commt ref 63ad84c, you have to specify -m and use parent 1 as a base:
IPv6 (Internet Protocol version 6) is a network-layer protocol that provides an identification and location system for
devices on the internet. It is the successor to IPv4 (Internet Protocol version 4), which has been the dominant protocol
used on the internet for many years.
IPv6 was developed to address the limitations of IPv4, primarily the exhaustion of available IP addresses. IPv4 uses a
32-bit address format, which allows for approximately 4.3 billion unique addresses. With the rapid growth of internet-
connected devices, IPv4 addresses were being depleted, leading to the need for a new protocol.
IPv6 uses a 128-bit address format, which provides an enormous address space capable of accommodating an
exponentially larger number of devices. The number of unique IPv6 addresses is approximately 340 undecillion
(3.4×10^38), which essentially eliminates the address exhaustion problem of IPv4.
In addition to the expanded address space, IPv6 offers several other improvements over IPv4. These include improved
security, simplified network configuration, better support for multicast communication, and built-in support for
features like auto-configuration and mobility.
Ping is a network utility used to test the reachability and latency (round-trip time) of a network device or host. It works
by sending ICMP (Internet Control Message Protocol) Echo Request messages to the target device and waiting for
ICMP Echo Reply messages in response.
The user initiates a ping command, specifying the IP address or hostname of the target device they want to test.
The source device (where the ping command is executed) creates an ICMP Echo Request message that includes
a unique identifier and sequence number.
The ICMP Echo Request message is encapsulated into an IP packet, with the source and destination IP
addresses set accordingly.
The IP packet is sent over the network to the destination device.
When the destination device receives the ICMP Echo Request, it generates an ICMP Echo Reply message.
The ICMP Echo Reply message is then sent back to the source device following the reverse path.
Once the source device receives the ICMP Echo Reply, it calculates the round-trip time by comparing the
timestamp from the original ICMP Echo Request with the timestamp in the ICMP Echo Reply.
The round-trip time, along with other statistics such as packet loss, is displayed to the user.
Ping can help determine if a device is reachable and measure the time it takes for packets to travel between the
source and destination. It's commonly used to diagnose network connectivity issues, troubleshoot network problems,
and measure network performance.
19) I type http:// www.yahoo.com in my browser’s URL bar and I press enter. What happens ? (discuss at every OSI
layer - Physical, data link, network, transport, session, presentation, application)
When you type http:// www.yahoo.com in your browser's URL bar and press enter, a series of processes occur across
different layers of the OSI (Open Systems Interconnection) model. Let's break down the steps at each OSI layer:
1) Physical Layer:
The physical layer deals with the transmission and reception of raw binary data over a physical medium (e.g., cables,
wireless signals). In this case, your computer sends electrical signals or light pulses (depending on the medium, such
as Ethernet or Wi-Fi) to the network.
This layer is responsible for framing the data into frames and ensuring reliable transmission over the physical layer. If
you are using a wired connection, the data link layer might include Ethernet frames. If it's a wireless connection, it
could involve Wi-Fi frames. Your computer sends out frames containing the destination MAC address, which is
resolved through ARP (Address Resolution Protocol) if necessary.
3) Network Layer:
The network layer deals with logical addressing and routing. In this case, your computer determines the IP address of
www.yahoo.com. If it doesn't have the IP address cached, it may send a DNS (Domain Name System) request to a
DNS server to resolve www.yahoo.com to its IP address. Once the IP address is obtained, your computer creates a
packet with the destination IP address.
4) Transport Layer:
The transport layer is responsible for end-to-end communication between devices and ensures that data is delivered
reliably. Your computer chooses a transport protocol, typically TCP (Transmission Control Protocol) for HTTP traffic.
TCP segments the data into smaller packets, assigns sequence numbers, and establishes a connection with the server
at www.yahoo.com.
5) Session Layer:
The session layer manages sessions or connections between applications. It sets up, maintains, and terminates
sessions. In the context of web browsing, a session is established between your browser and the Yahoo server. This
layer may not be explicitly involved in every step, as modern applications often handle session management
themselves.
6) Presentation Layer:
The presentation layer is responsible for translating between the application layer and the lower layers. It deals with
data format translation, encryption, and compression. In the context of web browsing, this layer may handle tasks
such as encoding and decoding data, but it's often less noticeable in modern internet communication.
7) Application Layer:
The application layer is where the actual user interface resides. In this case, your web browser (e.g., Chrome, Firefox)
is the application that initiates the communication. The browser uses the HTTP (Hypertext Transfer Protocol) to
request the web page from www.yahoo.com. It sends an HTTP GET request to the server, specifying the resource (web
page) it wants.
In summary, when you type http:// www.yahoo.com and press enter, your computer goes through these OSI layers,
initiating a process that involves translating the human-readable URL into an IP address, establishing a connection,
and requesting the desired web page from the Yahoo server. The server responds by sending back the requested web
page data, and your browser then interprets and displays it to you.
A virtual IP address (VIP) is an IP address that is not assigned to a specific physical network interface or device but is
instead associated with a virtual resource or service. It is typically used in scenarios where there is a need for high
availability, load balancing, or service redirection.