ChatGPT解决这个技术问题 Extra ChatGPT

How to interactively (visually) resolve conflicts in SourceTree / git

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.

g
gtrig

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.


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 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
After following all the steps to configure "Launch External Merge Tool" is still dimmed for me, no way to activate it
Also I was not selecting the merge conflict file, once I did that it went fine
I had to click on the "Uncommited changes" item in the commit list before it un-greyed.
C
Community

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:

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. Unzip TortoiseIDiff.exe and TortoiseMerge.exe to any folder (c:\Program Files (x86)\Atlassian\SourceTree\extras\ in my case). In SourceTree open Tools > Options > Diff > External Diff / Merge. Select TortoiseMerge in both dropdown lists. 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.


o
ozkary

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