Here are the frequent GIT merge conflict horror stories one might encounter when one pulls the latest code changes or when the project code is rebased. If you are using GIT bash, its quite easy to configure the GIT environment with a visual GUI tool called DiffMerge that helps you clearly see the lines of code causing the conflict and resolve the merge conflict with a “single click”.
Problem:
Merge conflicts while doing git pull
Output 1:
git pull Enter passphrase for key '/c/Users/arvenkataraman/.ssh/id_rsa': Auto-merging testSuite/sample.xml CONFLICT (content): Merge conflict in testSuite/sample.xml Automatic merge failed; fix conflicts and then commit the result. |
Output 2:
git pull --rebase U testSuite/sample1.xml U testSuite/sample2.xml U testSuite/sample3.xml M testSuite/sample4.xml U testSuite/sample5.xml U testSuite/sample6.xml U testSuite/sample7.xml M testSuite/sample8.xml M testSuite/sample9.xml Pull is not possible because you have unmerged files. Please, fix them up in the work tree, and then use 'git add/rm ' as appropriate to mark resolution, or use 'git commit -a'. |
Output 3:
git pull Falling back to patching base and 3-way merge... Auto-merging testSuite/sample.xml CONFLICT (content): Merge conflict in testSuite/ sample.xml Auto-merging testSuite/sample2.xml CONFLICT (content): Merge conflict in testSuite/ sample2.xml Auto-merging testSuite/sample3.xml CONFLICT (content): Merge conflict in testSuite/ sample3.xml Failed to merge in the changes. Patch failed at 0001 test changes |
Solution
Step 1: Download DiffMerge tool
The SourceGear DiffMerge tool could be downloaded from the below location:
http://www.sourcegear.com/diffmerge/downloads.php
Step 2: Configure GIT to use DiffMerge tool
Open GIT Bash and navigate to the GIT repository. Then give the below commands to configure GIT with the downloaded DiffMerge tool
git config --global merge.tool diffmerge git config --global mergetool.diffmerge.cmd "C:/\"Program Files\"/\"SourceGear\"/Common/DiffMerge/sgdm.exe --merge --result=\$MERGED \$LOCAL \$BASE \$REMOTE" git config --global mergetool.diffmerge.trustExitCode true |
Step 3: Invoke DiffMerge from GIT bash
If the git pull command doesn’t succeed due to merge conflict, please give the below command:
git difftool |
The DiffMerge opens up as below with automatically selected merge conflict files for comparison

Step 4: Shift the highlighted piece of code to resolve the merge conflict
On the top of the DiffMerge tool there is an arrow to apply changes from the right to left:

The files are displayed side-by-side for comparision and the differential piece of code to be merged is highlighted in violet color:

Select the piece of code highlighted and click on the “apply changes from the right” arrow at the top. After merge the code will look like below:

Similarly we could resolve all the merge conflicts with a single click. It is a lot more easier since this is a visual tool for merge.




















