git/svn diff可视化工具配置

标签: git diff  svn diff

 以前一直使用svn diff / git diff,看到的都是console下的对比提示。 今天花了点时间找了一款工具,基于GUI的diff操作。

 

软件

选择的是p4merge , 下载路径: http://www.perforce.com/perforce/downloads/index.html

 

下载完成后,直接解压缩到 /usr/local/program/p4merge 目录

 

git diff配置

1. 创建相应脚本

gitmerge.sh脚本:

#!/bin/sh
/usr/local/program/p4merge/bin/p4merge $*

 

gitdiff.sh脚本:

#!/bin/sh
[ $# -eq 7 ] && gitmerge.sh "$2" "$5"

 

2. 配置git diff/merge命令

git config --global merge.tool gitmerge
git config --global mergetool.gitmerge.cmd   'gitmerge.sh "$BASE" "$LOCAL" "$REMOTE" "$MERGED"'
git config --global mergetool.trustExitCode false
git config --global diff.external gitdiff.sh

 or  直接 vi ~/.gitconfig

[merge]
         tool = gitmerge
[mergetool "gitmerge"]
        cmd = gitmerge.sh \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
[mergetool]
        trustExitCode = false
[diff]
        external = gitdiff.sh

svn diff配置

1.  创建相应脚本

svndiff.sh脚本:

#!/bin/sh
shift 5
gitmerge.sh "[email protected]"
#vimdiff -f "[email protected]"

svnmerge.sh脚本:

 

2. 配置svn diff命令

vi ~/.subversion/config

 

diff-cmd = svndiff.sh
merge-tool-cmd = gitmerge.sh

 

效果

 



参考资料

 

原文链接:加载失败,请重新获取