OSX下git diff/merge 可視化工具 P4Merge 環境配置步驟

下載git

step1:首先,把要運行的命令放入外部包裝腳本中,建立一個merge包裝腳本,名字叫作extMerge,讓它帶參數調用P4Merge。app

$ cat >> /usr/local/bin/extMerge
#!/bin/sh
/Applications/p4merge.app/Contents/MacOS/p4merge $*

step2:再來建立一個名字爲extDiff的腳本。工具

$ cat >> /usr/local/bin/extDiff 
#!/bin/sh
[ $# -eq 7 ] && /usr/local/bin/extMerge "$2" "$5"

step3:更改權限,使這兩個腳本可執行blog

$ sudo chmod +x /usr/local/bin/extMerge 
$ sudo chmod +x /usr/local/bin/extDiff

step4:接下來在git裏配置自定義的diff和merge工具。退出root用戶,在本地用戶下,執行下面命令 。get

$ git config --global merge.tool extMerge
$ git config --global mergetool.extMerge.cmd \'extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"'
$ git config --global mergetool.trustExitCode false
$ git config --global diff.external extDiff
相關文章
相關標籤/搜索