Git比较与超越比较 [英] Git Diff with Beyond Compare

查看:155
本文介绍了Git比较与超越比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功地让git启动了Beyond Compare 3作为diff工具,但是当我做一个diff时,我正在比较的文件没有被加载。只有最新版本的文件被加载,没有别的,所以在Beyond Compare的右窗格中没有任何东西。



我在Cygwin上运行git 1.6.3.1超越比较3.我已经建立了超越比较,因为他们建议在他们的网站的支持部分与这样的脚本:

  #!/ bin / sh 
#diff被git用7个参数调用:
#path old-file old-hex old-mode new-file new-hex new-mode
path_to_bc3_executable $ 2$ 5| cat

有没有其他人遇到过这个问题,并知道解决方案?

编辑:

我遵循了VonC的建议,但我仍然遇到与以前完全相同的问题。我有点新Git,所以也许我没有正确地使用diff。



例如,我试图用类似这样的命令在文件上看到diff:

git diff main.css



Beyond Compare将会打开并且只显示当前的左侧窗格中的main.css,右侧窗格中没有任何内容。我希望看到我目前在左窗格中的main.css与HEAD相比,基本上是我上次承诺的。



我的git-diff-wrapper.sh如下所示:

 #!/ bin / sh 
#diff由7个参数通过git调用:
#路径old-file old-hex旧模式新文件new-hex新模式
c:/ Program Files / Beyond Compare 3 / BCompare.exe$ 2$ 5| cat

我的git配置看起来像这样:Diff:

  [diff] 
external = c:/cygwin/bin/git-diff-wrapper.sh


解决方案

我不使用额外的包装.sh文件。我的环境是Windows XP,cygwin上的git 1.7.1和Beyond Compare 3.以下是我的 .git / config 文件。

<$ p $
工具= bc3
[difftool]
提示符= false
[difftoolbc3]
#use cygpath to将cygwin路径$ LOCAL(类似于/ tmp / U5VvP1_abc)转换为windows路径,因为bc3是一个Windows软件
cmd = \c:/ program files / beyond compare 3 / bcomp.exe\$ (cygpath -w $ LOCAL)$ REMOTE
[合并]
工具= bc3
[mergetool]
提示符= false
[mergetoolbc3]
#trustExitCode = true
cmd = \c:/ program files / beyond compare 3 / bcomp.exe\$ LOCAL$ REMOTE$ BASE$ MERGED

然后,我使用 $ git difftool



关于 trustExitCode
对于自定义合并命令,指定th的退出代码e合并命令可用于确定合并是否成功。如果未设置为true,则检查合并目标文件时间戳,如果文件已更新,则假定合并已成功,否则将提示用户指示合并成功。

I have succeeded in getting git to start Beyond Compare 3 as a diff tool however, when I do a diff, the file I am comparing against is not being loaded. Only the latest version of the file is loaded and nothing else, so there is nothing in the right pane of Beyond Compare.

I am running git 1.6.3.1 with Cygwin with Beyond Compare 3. I have set up beyond compare as they suggest in the support part of their website with a script like such:

#!/bin/sh  
# diff is called by git with 7 parameters:  
# path old-file old-hex old-mode new-file new-hex new-mode  
"path_to_bc3_executable" "$2" "$5" | cat

Has anyone else encountered this problem and know a solution to this?

Edit:
I have followed the suggestions by VonC but I am still having exactly the same problem as before. I am kinda new to Git so perhaps I am not using the diff correctly.

For example, I am trying to see the diff on a file with a command like such:
git diff main.css

Beyond Compare will then open and only display my current main.css in the left pane, there is nothing in the right pane. I would like the see my current main.css in the left pane compared to the HEAD, basically what I have last committed.

My git-diff-wrapper.sh looks like this:

#!/bin/sh  
# diff is called by git with 7 parameters:  
# path old-file old-hex old-mode new-file new-hex new-mode  
"c:/Program Files/Beyond Compare 3/BCompare.exe" "$2" "$5" | cat

My git config looks like this for Diff:

[diff]  
external = c:/cygwin/bin/git-diff-wrapper.sh

解决方案

I don't use extra wrapper .sh files. My environment is Windows XP, git 1.7.1 on cygwin, and Beyond Compare 3. Following is my .git/config file.

[diff]
    tool = bc3
[difftool]
    prompt = false
[difftool "bc3"]
    #use cygpath to transform cygwin path $LOCAL (something like /tmp/U5VvP1_abc) to windows path, because bc3 is a windows software
    cmd = \"c:/program files/beyond compare 3/bcomp.exe\" "$(cygpath -w $LOCAL)" "$REMOTE"
[merge]
    tool = bc3
[mergetool]
    prompt = false
[mergetool "bc3"]
    #trustExitCode = true
    cmd = \"c:/program files/beyond compare 3/bcomp.exe\" "$LOCAL" "$REMOTE" "$BASE" "$MERGED"

Then, I use $ git difftool to compare and $ git mergetool to merge.

About trustExitCode: For a custom merge command, specify whether the exit code of the merge command can be used to determine whether the merge was successful. If this is not set to true then the merge target file timestamp is checked and the merge assumed to have been successful if the file has been updated, otherwise the user is prompted to indicate the success of the merge.

这篇关于Git比较与超越比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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