p4merge错误[GIT]

时间:2009-05-14 22:48:02

标签: git perforce git-p4 p4merge

我正在尝试使用带有git的p4merge,但我得到了:

启动p4merge时出错:“path / myFile”是(或指向)无效文件(这会列出文件的BASE,LOCAL,REMOTE和标准版本)。

Git告诉我有关冲突然后它询问我是否要启动mergetool配置(p4merge)然后我得到上面的错误。

附加说明:它适用于任何文件!

关于这是什么以及如何解决它的任何线索?

2 个答案:

答案 0 :(得分:39)

这对我在Windows 7上使用msysGit起作用了:

git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd 'p4merge $BASE $LOCAL $REMOTE $MERGED'

不确定为什么,但引用为我搞砸了。

答案 1 :(得分:8)

您将see here我的配置为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'不存在......)

刚刚测试过它(事实证明,你可以download and install only p4merge - 部分客户端/可视化合并工具 - 即使你没有安装任何其他P4产品)。

使用上面描述的设置,MSysGit1.6.3,DOS会话或Git bash会话:
它只是工作 TM


更新 msysgit 1.7.x

Benjol在评论中提及:

  

现在msysgit 本身支持p4merge。

     

这意味着您可以这样做:

git config --global merge.tool p4merge
# and I recommend 
git config --global mergetool.keepBackup false