Merging branches in git

We can merge branches in 2 ways.
  • Fast forward
  • 3 way merge
Fast forward merging Below image shows how the fast forward merge works in Git. From master branch, we created new feature branch and added 2 commits into it. Meanwhile master branch has no new commits. In this case, merging is done by pointing the HEAD to tip of feature branch. 3 Way merging Below image shows how the 3 way merge works in Git. From master branch, we created new feature branch and added 2 commits into it. Meanwhile master branch has also got one new commit. In this case, merging is done by creating new commit (after removing conflicts if any) and pointing the HEAD to the new commit. In below image, we are trying to merge branch x into master branch. But since there are conflicts, fast forward merge is not possible. In this case, you can use git status command to view what files are in conflict, resolve those conflicts and finally commit the changes.
 

Here is the output of above example.


Web development and Automation testing

solutions delivered!!