以前一直使用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脚本:
1.#!/bin/sh
2./usr/local/program/p4merge/bin/p4merge $*
gitdiff.sh脚本:
1.#!/bin/sh
2.[ $# -eq 7 ] && gitmerge.sh "$2" "$5"
2. 配置git diff/merge命令
1.git config --global merge.tool gitmerge
2.git config --global mergetool.gitmerge.cmd 'gitmerge.sh "$BASE" "$LOCAL" "$REMOTE" "$MERGED"'
3.git config --global mergetool.trustExitCode false
4.git config --global diff.external gitdiff.sh
or 直接 vi ~/.gitconfig
1.[merge]
2. tool = gitmerge
3.[mergetool "gitmerge"]
4. cmd = gitmerge.sh \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
5.[mergetool]
6. trustExitCode = false
7.[diff]
8. external = gitdiff.sh
svn diff配置
1. 创建相应脚本
svndiff.sh脚本:
1.#!/bin/sh
2.shift 5
3.gitmerge.sh "$@"
4.#vimdiff -f "$@"
svnmerge.sh脚本:
2. 配置svn diff命令
vi ~/.subversion/config
1.diff-cmd = svndiff.sh
2.merge-tool-cmd = gitmerge.sh
效果