1. 下載軟件
https://www.perforce.com/downloads/visual-merge-tool
若是頁面打不開,就經過官網查詢,搜索一下p4merge
2. 找到軟件的執行路徑
安裝完成之後,默認的執行文件在 /Applications/p4merge.app/Contents/MacOS/p4mergegit
3. 建立2個腳本
/usr/local/bin/gitmerge.shbash
#!/bin/sh /Applications/p4merge.app/Contents/MacOS/p4merge $*
/user/local/bin/gitdiff.shapp
#!/bin/sh [ $# -eq 7 ] && /usr/local/bin/gitmerge "$2" "$5"
設置文件權限
chmod 755 gitmerge.sh gitdiff.shcode
4. 配置git選項get
git config --global merge.tool gitmerge git config --global mergetool.gitmerge.cmd 'gitmerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"' git config --global mergetool.trustExitCode false git config --global diff.external gitdiff
或者能夠直接修改 ~/.gitconfig文件cmd
5. 使用
查看2個branch的修改文件列表
$ git diff --stat ANOTHER-BRANCHit
用p4merge查看2個branch當個文件的修改
$ git diff ANOTHER-BRANCH "DIFF-FILE-PATH"io