这两天花了点时间最终在Window和Mac上把Beyong Compare和git整合好。当中遇到到非常多坑,如今把这些都分享出来。希望对大家有帮助。
首先如果你已经装好了Beyong Compare。
然后在~/bin/文件夹下新建一个git-diff-wrapper.sh
window系统的git bash的git-diff-wrapper.sh
#!/bin/sh
# diff is called by git with 7 parameters:
# path old-file old-hex old-mode new-file new-hex new-mode
"D:/tools/Beyond Compare 2/BC2.exe" "$2" "$5" | cat
mac系统的git-diff-wrapper.sh
#/bin/sh
# diff is called by git with 7 parameters:
# path old-file old-hex old-mode new-file new-hex new-mode
bcompare "$2" "$5"|cat
注意: 你在mac系统中装了beyong compare后须要在菜单条点击“ Install Command Line Tools ”把它增加到命令行。
Beyond Compare Pro for Mac 4.0.2
在用户文件夹~下改动.gitconfig文件
[ user ]
name = hudashi
email = hudashi@gmail . com
[ diff ]
external = ~ /bin/ git - diff - wrapper . sh
最后就git diff就ok了。
注意: 我们在Mac上执行git diff时, 因为系统要保存历史文件到暂时文件夹再进行比較, 而在保存到暂时文件夹又须要非常高的权限。 所以我在git diff前加了 sudo 才干执行成功。即 sudo git diff .
关于git diff的很多其它内容请參考《 》