139

I'm using (Windows) SourceTree for my git project. I can do it in either command prompt or Linux terminal.

But, I'm wondering whether there is a nice way to interactively and visually resolve conflicts. For example, if pull detects conflicts, popping up a GUI-based conflict tool (e.g., P4Merge). Is it possible?

I am always doing manual conflict resolving, which is just painful.

This is, for example, a git pull message, from SourceTree.

git -c diff.mnemonicprefix=false -c core.quotepath=false pull --no-commit origin master
From W:\repo\
 * branch            master     -> FETCH_HEAD   

Updating 33c07bf..41e0249

error: Your local changes to the following files would be overwritten by merge:
    foo.cpp
    goo.cpp
    goo.hpp
Please, commit your changes or stash them before you can merge.
Aborting    

Completed with errors, see above.
Camilo Martinez
  • 1,723
  • 2
  • 21
  • 26
Nullptr
  • 3,103
  • 4
  • 27
  • 28

3 Answers3

156

From SourceTree, click on Tools->Options. Then on the "General" tab, make sure to check the box to allow SourceTree to modify your Git config files.

Then switch to the "Diff" tab. On the lower half, use the drop down to select the external program you want to use to do the diffs and merging. I've installed KDiff3 and like it well enough. When you're done, click OK.

Now when there is a merge, you can go under Actions->Resolve Conflicts->Launch External Merge Tool.

gtrig
  • 12,550
  • 5
  • 28
  • 36
  • 5
    I tried this, but at the end, I don't see beyond compare being launched. I see compare files being generated, but that's it. I cannot resolve conflict. Changing this to the standard / default compare doesn't seem to help either. – Echiban Nov 29 '13 at 16:39
  • You can also access the external merge by right-clicking on the files shown in the file list. – Diodeus - James MacFarlane Jan 23 '14 at 19:00
  • 1
    @echiban You probably have the standard license for Beyond Compare which does not accept 3 way merging. You need to go pro to use it as a git mergetool – pierdevara Feb 12 '14 at 22:50
  • 11
    After following all the steps to configure "Launch External Merge Tool" is still dimmed for me, no way to activate it – pal4life Jun 18 '14 at 15:56
  • @pal4life i had the same issue. restart Sourcetree after doing the above and it was no longer greyed out. – Choco Smith Jul 31 '14 at 07:26
  • 2
    Also I was not selecting the merge conflict file, once I did that it went fine – pal4life Aug 01 '14 at 17:47
  • 2
    I had to click on the "Uncommited changes" item in the commit list before it un-greyed. – Micah Zoltu Sep 08 '15 at 19:20
13

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.

Community
  • 1
  • 1
trejder
  • 17,148
  • 27
  • 124
  • 216
5

When the Resolve Conflicts->Content Menu are disabled, one may be on the Pending files list. We need to select the Conflicted files option from the drop down (top)

hope it helps

ozkary
  • 2,436
  • 1
  • 21
  • 20