在OS X上使用git + DiffMerge存在问题 [英] Problem with git + DiffMerge on OS X

查看:134
本文介绍了在OS X上使用git + DiffMerge存在问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下指令将Sourcegear DiffMerge配置为我的默认git合并工具:

  git config --global diff .tool diffmerge 
git config --global difftool.diffmerge.cmddiffmerge \\ $ LOCAL \\\ $ REMOTE \

git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmddiffmerge --merge --result = \\ $ MERGED \
\\ $ LOCAL \\\ $ BASE \\\ $ REMOTE \
git config --global mergetool.diffmerge.trustexitcode false

来源: http://www.andrejkoelewijn.com/wp/2010/01/08/configure-diffmerge-with-git/



但是,当我运行 git mergetool 时,出现以下错误:



这个问题的原因是什么?

解决方案

它有可能没有 $ BASE 文件,例如,如果合并的两个文件没有共同的祖先,或者在应用或重新绑定文件时碰巧发生冲突补丁而不是合并分支。在这种情况下,虽然 $ BASE 变量仍然会被设置,但是那里没有文件。

在您的mergetool命令中,您需要检查是否存在 $ BASE ,并且执行没有共同祖先的合并如果没有。它看起来并不像DiffMerge支持那种模式(它支持合并没有共同祖先的两个文件,但它总是将输出写入其中一个文件,而不是结果文件)。相反,如果 > $ BASE 文件,则需要传入 $ LOCAL $ BASE 不存在:

$ g $ git config --global mergetool.diffmerge.cmd'diffmerge - -merge --result =$ MERGED$ LOCAL$(如果测试-f$ BASE;然后回显$ BASE;否则回显$ LOCAL; fi)$ REMOTE'


I have configured Sourcegear DiffMerge to be my default git merge tool using the following instructions:

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

Source: http://www.andrejkoelewijn.com/wp/2010/01/08/configure-diffmerge-with-git/

However when I run git mergetool I get the following error:

What could be the cause of this issue?

解决方案

It is possible that there will be no $BASE file, if for instance the two files being merged have no common ancestor, or if you happen to get the conflict when applying or rebasing a patch rather than merging branches. In this case, while the $BASE variable will still be set, there will be no file there.

In your mergetool command, you need to check whether $BASE exists, and do a merge without a common ancestor if it does not. It doesn't look like DiffMerge supports that mode (it supports merging two files with no common ancestor, but it always writes the output to one of the files, not a result file). Instead, you'll need instead to pass in $LOCAL as the $BASE file if $BASE does not exist:

git config --global mergetool.diffmerge.cmd 'diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"'

这篇关于在OS X上使用git + DiffMerge存在问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆