首页 > 代码库 > mac配置git mergetool为p4merge(2013笔记整理)
mac配置git mergetool为p4merge(2013笔记整理)
既有环境:
1)下载安装p4merge
2)安装git
下面是配置p4merge为git mergetool的步骤
1. /usr/local/bin下创建extMerge文件:
?
1 2 3 | $ cat >> /usr/local/extMerge #!/bin/sh /Applications/IDE/p4merge .app /Contents/MacOS/p4merge $* |
2. /usr/local/bin下创建extDiff文件:
?
1 2 3 | $ cat >> /usr/local/bin/extDiff #!/bin/sh [ $ # -eq 7 ] && /usr/local/bin/extMerge "$2" "$5” |
3. extMerge和extDiff文件添加执行权限
?
1 2 | $ sudo chmod +x /usr/local/bin/extMerge $ sudo chmod +x /usr/local/bin/extDiff |
4. 命令行配置本地git配置信息
?
1 2 3 4 5 6 7 8 9 10 11 | $ 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文件
?
1 2 3 4 5 6 7 8 9 10 11 | [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之后的文件。
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。