Kannan Sudhakaran has Published 20 Articles

Explain mixed reset with an example in Git

Kannan Sudhakaran

Kannan Sudhakaran

Updated on 30-Apr-2021 08:15:25

179 Views

Mixed reset will move the HEAD pointer to the commit specified. This is the default reset option in git. It also copies content of the commit snapshot to the staging area and not to the working directory. This will lead to overwriting the staging area. The working directory contents will ... Read More

Explain how reset command works in Git

Kannan Sudhakaran

Kannan Sudhakaran

Updated on 30-Apr-2021 08:11:58

790 Views

The commit command moves the HEAD of a branch implicitly. The below diagram shows that initially HEAD was pointing to commit c1. After each commit operation the HEAD pointer moves ahead to the new commit. We can perform a reset using the HEAD pointer or commit hash.The git reset command ... Read More

How to abort a merge conflict in Git?

Kannan Sudhakaran

Kannan Sudhakaran

Updated on 30-Apr-2021 08:03:28

2K+ Views

When doing a merge, you may run into one or more conflicts. Now what if we are not quite ready to handle this conflict yet. Perhaps you have several conflicts and you don't have enough time to spend on resolving these conflicts. In situations like this we can easily go ... Read More

What is merge conflict in Git? How to handle merge conflicts?

Kannan Sudhakaran

Kannan Sudhakaran

Updated on 30-Apr-2021 08:01:14

720 Views

In real world, when we merge branches, we will run into conflicts quite often. Conflict happens because of the following reasons −When the same line of code is changed in different ways in two branches.A given file is changed in one branch but deleted in another branch.Same file is added ... Read More

How to view merged and unmerged branches in Git?

Kannan Sudhakaran

Kannan Sudhakaran

Updated on 30-Apr-2021 07:48:08

6K+ Views

When we have multiple branches in a git repository, we would need to bring the changes from all the branches to the main line of work that is the master branch. So, if we are currently in master branch and need to see which branches need to be merged, we ... Read More

How to disable fast forward merges? What are its pros and cons in Git?

Kannan Sudhakaran

Kannan Sudhakaran

Updated on 30-Apr-2021 07:46:06

2K+ Views

Fast forward merges can be disabled −At the time of mergingFor the entire repositoryFor all repositories.Disabling fast forward merges has both pros and cons.When we disable fast forward merge, git will perform a merge commit to merge the changes from both the branches. The drawback of merge commit is that ... Read More

What is 3-way merge or merge commit in Git?

Kannan Sudhakaran

Kannan Sudhakaran

Updated on 30-Apr-2021 07:43:00

5K+ Views

Let us look at an example of a 3-way merge. In this example, the Feature branch is two commits ahead of the Master branch.Diagram 1Before we merge it with Master, let us say we have added an additional commit to the Master as shown in the below diagram.Diagram 2Due to ... Read More

What is a fast-forward merge in Git?

Kannan Sudhakaran

Kannan Sudhakaran

Updated on 30-Apr-2021 07:34:00

24K+ Views

Fast forward merge can be performed when there is a direct linear path from the source branch to the target branch. In fast-forward merge, git simply moves the source branch pointer to the target branch pointer without creating an extra merge commit.Let us look at an example implementing fast-forward merge.We ... Read More

How can we diverge two branches in Git?

Kannan Sudhakaran

Kannan Sudhakaran

Updated on 30-Apr-2021 07:23:23

2K+ Views

A branch in git is a series of interrelated commits. If two branches follow a non-linear path then they diverge each other. The diagram shows two diverged branches master and feature.Consider the above diagram. Let us assume that both the branches were following a linear path before the initial commit. ... Read More

Explain hard reset with an example in Git

Kannan Sudhakaran

Kannan Sudhakaran

Updated on 29-Apr-2021 11:19:45

121 Views

The diagram shows a file named File1.txt within the git repository. A, B, C and D represent lines that are added to the file. The diagram indicates that a commit is performed after adding each line A, B and C. c1 is the commit performed after adding line A, c2 ... Read More

Advertisements