Resolving conflicts in git

When merging the branches, we often come across the conflicts. When same files are changes in both branches, conflicts occur.

Viewing the conflicts

When merging the branch, we get error message saying there is conflict as shown below. We can also view the files that are in conflict using git status command. Below image shows that in both branches ( x and master), file f1.txt has been changed. To view the conflicts in specific file, use below command. Changes made in local copy are shown between
 
 <<<<<<< HEAD and =======.
Changes made in other branch are shown between
 
======= and >>>>>>>
After resolving the conflict, you have to add the files into staging area and commit the changes. When all conflicts are resolved and committed, merging process is finished. Here is the output of above example.


Complex problems, Simple Solutions