p4merge 错误 [GIT]
题
我正在尝试将 p4merge 与 git 一起使用,但我得到:
启动 p4merge 时出错:“path/myFile”是(或指向)无效文件 (这列出了文件的 BASE、LOCAL、REMOTE 和标准版本)。
Git 告诉我有关冲突的信息,然后它询问我是否要启动配置的合并工具 (p4merge),然后我收到上面的错误。
附加说明:任何文件都会发生这种情况!
关于这是什么以及如何解决它有任何线索吗?
解决方案
此在Windows 7上使用msysGit为我工作:
git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd 'p4merge $BASE $LOCAL $REMOTE $MERGED'
不知道为什么,但报价搞砸的事情了我。
其他提示
你会 看这里 我的 DiffMerge 或 KDiff3 配置。
基于此,我推荐 p4merge:
git config --global merge.tool merge
git config --global mergetool.merge.cmd "merge.sh \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" \"$PWD/$MERGED\""
和 merge.sh
作为包装器(复制到您引用的目录中) PATH
环境变量),能够考虑到没有的情况 BASE
存在。
(当在两个不同的分支中创建文件然后合并时,该文件将没有共同的祖先)
#!/bin/sh
# Passing the following parameters to mergetool:
# local base remote merge_result
alocal=$1
base=$2
remote=$3
result=$4
if [ -f $base ]
then
p4merge.exe -dl "$base" "$alocal" "$remote" "$result"
else
p4merge.exe -dl "$result" "$alocal" "$remote" "$result"
fi
您可能会注意到:
- 指某东西的用途
PWD
在合并的配置中 - 指某东西的用途 ”
merge
" 作为 merge.tool 名称的名称(因为实际的工具是在merge.sh
脚本,您可以在其中切换任意数量的合并工具) - 使用双引号
$base
,$alocal
,$remote
,$result
在脚本内 - 基于“基本”文件的存在来调用该工具的条件路径。
- 需要始终有 3 个文件作为参数进行合并(即使“base”不存在......)
刚刚测试了一下(事实证明,你可以 仅下载并安装 p4merge -- 客户端/可视化合并工具部分 --,即使您没有安装任何其他 P4 产品)。
使用上述设置,MSysGit1.6.3、DOS 会话或 Git bash 会话:
它只是有效TM值.
更新 msysgit 1.7.x
苯卓尔 评论中提到:
msysgit 现在原生支持 p4merge.
这意味着你可以这样做:
git config --global merge.tool p4merge
# and I recommend
git config --global mergetool.keepBackup false
不隶属于 StackOverflow