28

我正在尝试将 p4merge 与 git 一起使用,但我得到:

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

Git 告诉我冲突,然后它询问我是否要启动配置的合并工具(p4merge),然后我得到上面的错误。

附加说明:任何文件都会发生这种情况!

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

4

2 回答 2

39

这对我在 Windows 7 上使用 msysGit 有用:

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

不知道为什么,但引用把事情搞砸了。

于 2009-08-02T02:02:29.823 回答
9

您将在这里看到我的 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 个文件合并为参数(即使“基础”不存在......)

刚刚对其进行了测试(事实证明,即使您没有安装任何其他 P4 产品,您也只能下载和安装 p4merge——客户端/可视合并工具部分)。

使用上述设置,MSysGit1.6.3,DOS 会话或 Git bash 会话:
它只适用于TM


更新msysgit 1.7.x

Benjol在评论中提到:

p4merge 现在由 msysgit 本机支持

这意味着您可以这样做:

git config --global merge.tool p4merge
# and I recommend 
git config --global mergetool.keepBackup false
于 2009-05-15T06:01:22.690 回答