win与linux下git配置p4merge为合并比较工具的方法
程序员文章站
2022-05-19 17:38:51
...
首先去官方下载p4merge工具
1.http://www.perforce.com/downloads/complete_list
2.Browse by Platform>选择相应平台系统下载后安装
3.安装完毕后,在安装根目录下会有一个p4merge(.exe)的文件
Windows配置:
在Git配置中如下配置(请自己写明p4merge路径):
[diff] tool = p4m [difftool "p4m"] cmd = cmd = \"/cygdrive/d/development/Perforce/p4merge.exe\" \"$(cygpath -w $LOCAL)\" \"$REMOTE\" [merge] tool = p4m [mergetool "p4m"] cmd = \"/cygdrive/d/development/Perforce/p4merge.exe\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\" trustExitCode = true keepBackup = false
注:这里的tool别名不能写为p4merge,因为git在自己的tool-lib命令中,已经添加了这个别名,当别名符合它添加的这个规则时,git首先会调用它自身的规则方法,会导致在win中的路径出现错误
Linux配置:
1.创建文件/usr/local/bin/extDiff
#!/bin/bash /usr/bin/p4merge "$2" "$5"
2.确保文件可运行:
$ sudo chmod +x /usr/local/bin/extDiff
3.编辑~/.gitconfig:
[diff] external = extDiff [gui] spellingdictionary = none [mergetool] trustExitCode = false [merge] tool = p4merge [mergetool "p4merge" ] cmd = p4merge /"$BASE/" /"$LOCAL/" /"$REMOTE/" /"$MERGED/"
上一篇: 做一个合格的倾听者 谈话 倾听
下一篇: MySQL 程序式写法