Sourcetree无法为合并冲突打开Diffmerge

时间:2018-11-11 14:50:15

标签: atlassian-sourcetree diffmerge

最近,我重新安装了macOS。我已经安装了Sourctree和diffmerge并将diffmerge设置为默认合并工具。出于某种原因,每次我选择“解决冲突->打开外部合并工具”时,sourcetree都会打开其等待视图并直接将其关闭。

我在sourcetree中的设置页面:

enter image description here

这是当sourcetree为我配置差异合并时我的根.gitconfig的样子:

[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 = /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

3 个答案:

答案 0 :(得分:2)

出于某种原因,源树为命令行参数设置了无效的路径。

为解决此问题,我手动配置了Visual Diff工具和合并工具。

sourcetree中的“设置”页面

enter image description here

差异

命令:/usr/local/bin/diffmerge 参数--nosplash "$LOCAL" "$REMOTE"

合并

命令:/usr/local/bin/diffmerge 参数--nosplash --merge --result="$MERGED" "$LOCAL" "$BASE" "$REMOTE"

-nosplash参数是可选的,但可以防止在我开始工作之前总是必须关闭的(我认为无用)弹出窗口。

Git配置文件:

[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

有关diffmerge命令行参数的更多信息:

差异:https://sourcegear.com/diffmerge/webhelp/sec__clargs__diff.html

合并:https://sourcegear.com/diffmerge/webhelp/sec__clargs__merge.html

答案 1 :(得分:2)

我通过遵循DiffMerge Settings for OS X文档页面上的指示来解决了这个问题,该页面是:

首先确认/usr/local/bin/diffmerge存在。 如果您使用的是PKG安装程序,则该文件是在安装/Applications/DiffMerge.app时安装的。 如果您使用了DMG文件,请参考安装Extras的说明。

以下命令将更新您的.gitconfig,以使GIT使用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\""

然后我可以通过选择Sourcetree中的菜单选项来使用DiffMerge

Sourcetree preference pane, showing the Diff tab, with DiffMerge selected for the Visual Diff Tool and Merge Tool options

可选)您可能想要在其他参数之前将--nosplash添加到两个命令中,以避免出现初始屏幕(@saren-inden也建议)。即;

$ 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\""

答案 2 :(得分:0)

我遇到了同样的问题。单击外部差异时,也不会启动DiffMerge。

问题似乎是DiffMerge在 .gitconfig 文件中的路径: cmd = /Applications/DiffMerge.app/Contents/MacOS/DiffMerge/Contents/MacOS/DiffMerge ...

如果您检查路径/Applications/DiffMerge.app/Contents/MacOS/DiffMerge,则实际上它不是目录,而是文件。看来 SourceTree 在路径上两次添加了/Contents/MacOS/DiffMerge。我删除了重复的部分,外部差异开始工作。

没有尝试合并。