Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sourcetree fails to open Diffmerge for merge conflicts

Recently I had a fresh install of macOS. I've installed Sourctree and diffmerge and set diffmerge as the default merge tool. For some reason everytime when I select 'Resolve Conflicts -> Open External Merge Tool' sourcetree opens its waiting view and directly closes it.

My settings page in sourcetree:

enter image description here

This is how my root .gitconfig looks like when sourcetree configures diff merge for me:

[core]
    excludesfile = /Users/[username]/.gitignore_global
[user] 
    name = ---- -----
    email = [email protected]
[commit]
    template = /Users/[username]/.stCommitMsg
[credential]
    helper =  !/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/bin/java -Ddebug=false -Djava.net.useSystemProxies=true -jar /usr/local/Cellar/git-credential-manager/2.0.4/libexec/git-credential-manager-2.0.4.jar

[difftool "DiffMerge"]
[mergetool "DiffMerge"]
[diff]
    tool = diffmerge
[difftool "diffmerge"]
    cmd = /usr/local/bin/diffmerge \"$LOCAL\" \"$REMOTE\"
[merge]
    tool = diffmerge
[mergetool "diffmerge"]
    trustExitCode = true
    cmd = /usr/local/bin/diffmerge --merge --result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"
[difftool "sourcetree"]
    cmd = /Applications/DiffMerge.app/Contents/MacOS/DiffMerge/Contents/MacOS/DiffMerge --nosplash \"$LOCAL\" \"$REMOTE\"
path = 
[mergetool "sourcetree"]
    cmd = /Applications/DiffMerge.app/Contents/MacOS/DiffMerge/Contents/MacOS/DiffMerge --merge --result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"
    trustExitCode = true
like image 970
Saren Inden Avatar asked Nov 11 '18 14:11

Saren Inden


People also ask

How do I resolve merge conflicts in SourceTree?

For merge branch in Sourcetree you just need right click in the branch commit that you want and choose the option Merge. If you have some conflict you can also fix it by right clicking in the conflicted file, select the Resolve Conflicts and pick the desired option.

How do I add a DiffMerge in SourceTree?

SourceTree config First, open up the options window and go to Diff tab. Change both External Diff Tool and Merge Tool to Custom. In the Diff Command field enter the full path to the vsdiffmerge.exe. For VS 2015 and below you can find it in the Visual Studio installation folder, under Common7\IDE subfolder.

How do I add Kdiff3 to SourceTree?

There are two settings in sourcetree in the Tools->options menu under the Diff tab where you need to set it to Kdiff3: the diff tool and the merge tool. Ensure that both of them are configured to used Kdiff3.

Is DiffMerge free?

SourceGear DiffMerge is licensed for use free of charge. However, to help fund new feature development and ongoing product maintenance, SourceGear asks DiffMerge users to register the product for a small fee and receive a registration key.


1 Answers

This happend to me when diffmerge was installed via the pkg install instead of the installer. This appearantly does not configure your bash to know the command diffmerge so than you have to set the path to the diffmerge (or update your bin config).

To solve this I manually configured Visual Diff Tool and Merge Tool (with as benefit that you can disable that annoying splash screen on launch everytime).

Settings page in sourcetree

enter image description here

Diff

Command: /usr/local/bin/diffmerge Arguments --nosplash "$LOCAL" "$REMOTE"

Merge

Command: /usr/local/bin/diffmerge Arguments --nosplash --merge --result="$MERGED" "$LOCAL" "$BASE" "$REMOTE"

The --nosplash argument is optional but prevents the (in my opinion useless) pop up that you always have to close before you can start your work.

Git config file:

[core]
    excludesfile = /Users/[username]/.gitignore_global
[user]
    name = ---------
    email = [email protected]
[commit]
    template = /Users/[username]/.stCommitMsg
[credential]
    helper = !/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/bin/java -Ddebug=false -Djava.net.useSystemProxies=true -jar /usr/local/Cellar/git-credential-manager/2.0.4/libexec/git-credential-manager-2.0.4.jar

[difftool "DiffMerge"]
[mergetool "DiffMerge"]
[diff]
    tool = diffmerge
[difftool "diffmerge"]
    cmd = /usr/local/bin/diffmerge \"$LOCAL\" \"$REMOTE\"
[merge]
    tool = diffmerge
[mergetool "diffmerge"]
    trustExitCode = true
    cmd = /usr/local/bin/diffmerge --merge --result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"
[difftool "sourcetree"]
    cmd = /usr/local/bin/diffmerge --nosplash \"$LOCAL\" \"$REMOTE\"
    path = 
[mergetool "sourcetree"]
    cmd = /usr/local/bin/diffmerge --nosplash --merge --result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"
    trustExitCode = true

More info about diffmerge command line arguments:

Diff: https://sourcegear.com/diffmerge/webhelp/sec__clargs__diff.html

Merge: https://sourcegear.com/diffmerge/webhelp/sec__clargs__merge.html

like image 114
Saren Inden Avatar answered Oct 15 '22 23:10

Saren Inden