the*_*rty 8 git macos diffmerge
我已使用以下说明将Sourcegear DiffMerge配置为我的默认git合并工具:
git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd "diffmerge \"\$LOCAL\" \"\$REMOTE\""
git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd "diffmerge --merge --result=\"\$MERGED\"
\"\$LOCAL\" \"\$BASE\" \"\$REMOTE\""
git config --global mergetool.diffmerge.trustexitcode false
Run Code Online (Sandbox Code Playgroud)
资料来源:http://www.andrejkoelewijn.com/wp/2010/01/08/configure-diffmerge-with-git/
但是,当我运行时,git mergetool我收到以下错误:

这个问题可能是什么原因?
$BASE如果例如合并的两个文件没有共同的祖先,或者在应用或重新定位补丁而不是合并分支时碰巧遇到冲突,则可能没有文件.在这种情况下,虽然$BASE仍然会设置变量,但那里不会有文件.
在mergetool命令中,您需要检查是否$BASE存在,并在没有共同祖先的情况下进行合并(如果不存在).它看起来不像DiffMerge支持该模式(它支持合并两个没有共同祖先的文件,但它总是将输出写入其中一个文件,而不是结果文件).相反,你需要而不是传递$LOCAL的$BASE文件,如果$BASE不存在:
git config --global mergetool.diffmerge.cmd 'diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3131 次 |
| 最近记录: |