Sourcetree fails to open Diffmerge for merge conflicts

♀尐吖头ヾ 提交于 2019-12-05 17:58:09

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

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 = ---------@------.--
[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

I resolved this problem by following the instructions on the DiffMerge Settings for OS X documentation page, which was:

First confirm that /usr/local/bin/diffmerge is present. If you used the PKG Installer, this was installed when /Applications/DiffMerge.app was installed. If you used the DMG file, refer to the instructions for installing the Extras.

The following commands will update your .gitconfig to let GIT use DiffMerge:

$ git config --global diff.tool diffmerge
$ git config --global difftool.diffmerge.cmd
    "/usr/local/bin/diffmerge \"\$LOCAL\" \"\$REMOTE\""

$ git config --global merge.tool diffmerge
$ git config --global mergetool.diffmerge.trustExitCode true
$ git config --global mergetool.diffmerge.cmd 
    "/usr/local/bin/diffmerge --merge --result=\"\$MERGED\"
        \"\$LOCAL\" \"\$BASE\" \"\$REMOTE\""

I was then able to use DiffMerge by choosing the menu option in Sourcetree

(Optional) You may want to add --nosplash to both commands, before other parameters, to avoid the splash screen (as also recommended by @saren-inden). i.e.;

$ git config --global diff.tool diffmerge
$ git config --global difftool.diffmerge.cmd
    "/usr/local/bin/diffmerge --nosplash \"\$LOCAL\" \"\$REMOTE\""

$ git config --global merge.tool diffmerge
$ git config --global mergetool.diffmerge.trustExitCode true
$ git config --global mergetool.diffmerge.cmd 
    "/usr/local/bin/diffmerge --nosplash --merge --result=\"\$MERGED\"
        \"\$LOCAL\" \"\$BASE\" \"\$REMOTE\""
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!