p4merge错误[GIT]

Joh*_*dol 28 git perforce p4merge git-p4

我想用git使用p4merge,但我得到:

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

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

附加说明:它发生在任何文件!

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

Mik*_*enn 39

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

git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd 'p4merge $BASE $LOCAL $REMOTE $MERGED'
Run Code Online (Sandbox Code Playgroud)

不知道为什么,但引用搞砸了我.

  • 我使用`git config --global mergetool.p4merge.cmd'"C:\ Install Dir Has Spaces\p4merge.exe"$ BASE $ LOCAL $ REMOTE $ MERGED'` (3认同)

Von*_*onC 8

您将在此处看到我的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\""
Run Code Online (Sandbox Code Playgroud)

并且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
Run Code Online (Sandbox Code Playgroud)

你可能会注意到:

  • 使用PWD在合并的配置
  • 使用" merge"作为merge.tool名称的名称(因为在merge.sh脚本中调用实际工具,您可以在任意数量的合并工具之间切换)
  • 使用双引号括住的$base,$alocal,$remote,$result在脚本中
  • 基于"基础"文件的存在,调用工具的条件路径.
  • 需要总是有3个文件合并为参数(即使'base'不存在......)

刚刚测试过它(事实证明,即使您没有安装任何其他P4产品,您也可以下载并仅安装p4merge - 客户端/可视化合并工具部分).

使用上面描述的设置,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
Run Code Online (Sandbox Code Playgroud)

  • 注意:根据第3条评论[here](http://stackoverflow.com/questions/426026/git-on-windows-how-do-you-set-up-a-mergetool/436040#436040),p4merge是现在由msysgit原生支持.我不知道从哪个版本开始.这意味着你可以做`git config --global merge.tool p4merge`(我推荐`git config --global mergetool.keepBackup false`) (2认同)