mac配置git mergetool爲p4merge(2013筆記整理)

既有環境:git

1)下載安裝p4mergebash

2)安裝gitapp

 

下面是配置p4merge爲git mergetool的步驟spa

1. /usr/local/bin下建立extMerge文件:命令行

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

2. /usr/local/bin下建立extDiff文件:code

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

3. extMerge和extDiff文件添加執行權限blog

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

4. 命令行配置本地git配置信息rem

$ 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
$ git config -l
user.name=YuzhuXu/徐玉珠
user.email=timely.xyz@163.com
merge.tool=extMerge
mergetool.extMerge.cmd= extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
mergetool.trustexitcode=false
diff.external=extDiff

5. 配置完後,檢查.gitconfig文件get

[user]
        name = YuzhuXu/徐玉珠
        email = timely.xyz@163.com
[merge]
        tool = extMerge
[mergetool "extMerge"]
        cmd = " extMerge \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\""
[mergetool]
        trustExitCode = false
[diff]
        external = extDiff

6. 檢驗一下。使用p4merge之後會生成xxx.backup, xxx.base, xxx.local, xxx.remote, xxx.orig, 以及merge以後的文件。cmd

相關文章
相關標籤/搜索