git difftool Beyond Compare 4不区分本地和远程

git difftool Beyond Compare 4不区分本地和远程,git,beyondcompare,git-difftool,beyondcompare4,Git,Beyondcompare,Git Difftool,Beyondcompare4,我正在使用CYGWIN和Beyond Compare 4 Pro版。我已设置了以下.gitconfig文件: [diff] tool = bc3 [difftool "bc3"] path = c:/program files/beyond compare 4/bcomp.exe [merge] tool = bc3 [mergetool "bc3"] path = c:/program files/beyond compare 4/bcomp.exe 对本地文

我正在使用CYGWIN和Beyond Compare 4 Pro版。我已设置了以下.gitconfig文件:

[diff]
    tool = bc3
[difftool "bc3"]
    path = c:/program files/beyond compare 4/bcomp.exe
[merge]
    tool = bc3
[mergetool "bc3"]
    path = c:/program files/beyond compare 4/bcomp.exe
对本地文件做了一个小更改后,我在CYGWIN中运行以下命令:

git difftool
Beyond Compare 4正确启动,但仅左侧为红色。右边是空的

我希望在启动时将本地更改(左)与远程更改(右)进行简单比较


我假设这是默认行为?是否缺少另一个设置或此设置仅可用

您列出的配置应能在Windows命令提示符下正确使用Git for Windows 2.12.1.Windows.1。我还没有用Cygwin测试过


如果您使用的是Cygwin提供的Git版本,那么从切换到Windows版本的Git可能会有所帮助。在过去,Cygwin的Git版本明显落后于官方的Windows版本。要检查您的Git版本,请运行“Git--version”。

我可以通过将.gitconfig文件配置为以下内容来解决问题:

[difftool "bc3"]
     cmd = \"c:/program files/beyond compare 4/bcomp.exe\" "$(cygpath -w $LOCAL)" "$REMOTE"
这会在执行git difftool时产生本地和远程的差异,我必须在上面进行修改:

更进一步,与mergetool类似:

git config --system mergetool.bc.cmd '"c:/program files/beyond compare 4/bcomp.exe" "$(cygpath -w $LOCAL)" "$(cygpath -w $REMOTE)" "$(cygpath -w $BASE)" "$(cygpath -w $MERGED)"'
对于
core.editor
,如果要使用升华文本,需要使用包含以下命令的外部脚本
~/git editor.sh

cygpath --windows $@ | sed 's/\\/\\\\/g' | tr '\n' '\0' | xargs -0 -n1 /cygdrive/c/Program\ Files/Sublime\ Text\ 3/subl.exe -n -w
我修改了上面的

然后将其添加到git
core.editor
config:

git config --system core.editor "~/git-editor.sh"
如果您没有为编辑器使用外部脚本,那么如果您尝试将
$cygpath
放入
core.editor
配置中,git将导致Sublime text打开两个文件,因为git会将“错误路径”文件名附加到
core.editor
设置的末尾

git config --system core.editor "~/git-editor.sh"