Resolving Git conflicts in SourceTree

stackflow picture stackflow · Jun 11, 2014 · Viewed 15k times · Source

I was using NetBeans GIT plugin before, then I've decided to switch to SourceTree, as it is more efficient and powerful. As a newcomer to SourceTree I've managed to figure out basic Pull, Push and Commit workflows.

However, I got stuck when there were file conflicts when merging with my friend's work. In NetBeans if there are any conflicts, the plugin suggest to resolve it in a popup and I just want to go to the conflict resolving interface and accept the correct code chunk by clicking a button. That was simple.

In SourceTree, there is something called External Merge Tool which didn't work well for me. When I right click on the file with conflicts, it just opened up two files side by side and there were arrows pointing left to right in the middle. There is a dropdown at the bottom of the screen to select the arrow direction.

I tried to use this interface to resolve conflicts, but I failed. It didn't fix the conflicts and merged two files.

As I searched through the internet I found that some people use external SourceTree conflict solving plugins to merge. Actually I'm little lost here. That's why I've decided to post this problem here as this might help someone like me one day.

I know there are lots of people who have been using SourceTree for a long time. Could any of them please tell me, how to resolve conflicts in SourceTree effectively?

Should I use an external plugin or should I use the External Merge Tool (if so, how can I use this)?

Answer

trejder picture trejder · Sep 23, 2014

I'm using SourceTree along with TortoiseMerge/Diff, which is very easy and convinient diff/merge tool.

If you'd like to use it as well, then:

  1. Get standalone version of TortoiseMerge/Diff (quite old, since it doesn't ship standalone since version 1.6.7 of TortosieSVN, that is since July 2011). Links and details in this answer.

  2. Unzip TortoiseIDiff.exe and TortoiseMerge.exe to any folder (c:\Program Files (x86)\Atlassian\SourceTree\extras\ in my case).

  3. In SourceTree open Tools > Options > Diff > External Diff / Merge. Select TortoiseMerge in both dropdown lists.

  4. Hit OK and point SourceTree to your location of TortoiseIDiff.exe and TortoiseMerge.exe.

After that, you can select Resolve Conflicts > Launch External Merge Tool from context menu on each conflicted file in your local repository. This will open up TortoiseMerge, where you can easily deal with all the conflicts, you have. Once finished, simply close TortoiseMerge (you don't even need to save changes, this will probably be done automatically) and after few seconds SourceTree should handle that gracefully.

The only problem is, that it automatically creates backup copy, even though proper option is unchecked.

There is an alternate solution to this problem, which uses KDiff3 instead of TortoiseDiff / TortoiseMerge.