p4merge 错误 [GIT]

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/866262/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:41:04  来源:igfitidea点击:

p4merge error [GIT]

gitperforcegit-p4p4merge

提问by JohnIdol

I am trying to use p4merge with git but I am getting:

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

Error starting p4merge: "path/myFile" is (or points to) an invalid file(this lists the BASE, LOCAL, REMOTE, and standard version of the file).

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

Git tells me about the conflict then it asks if I wanna start the mergetool configured (p4merge) and then I get the error above.

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

Additional note: it happens with any file!

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

Any clue about what this is and how to fix it?

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

回答by Mike Glenn

This worked for me using msysGit on windows 7:

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

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

Not sure why but the quoting screwed things up for me.

不知道为什么,但引用对我来说搞砸了。

回答by VonC

You will see heremy config for DiffMerge or KDiff3.

您将在此处看到我的 DiffMerge 或 KDiff3 配置。

Based on that, I would recommend for p4merge:

基于此,我会推荐 p4merge:

git config --global merge.tool merge
git config --global mergetool.merge.cmd "merge.sh \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" \"$PWD/$MERGED\""

and merge.shbeing a wrapper (copied in a directory referenced by your PATHenvironment variable), able to take into account the case where no BASEexists.
(when a file is created in two different branches being then merged, there would be no common ancestor for that file)

并且merge.sh是一个包装器(复制到您的PATH环境变量引用的目录中),能够考虑不BASE存在的情况。
(当在两个不同的分支中创建文件然后合并时,该文件将没有共同的祖先)

#!/bin/sh

# Passing the following parameters to mergetool:
#  local base remote merge_result

alocal=
base=
remote=
result=

if [ -f $base ]
then
    p4merge.exe -dl "$base" "$alocal" "$remote" "$result" 
else
    p4merge.exe -dl "$result" "$alocal" "$remote" "$result" 
fi

You may note:

您可能会注意到:

  • the use of PWDin the config of the merge
  • the use of "merge" as name of the merge.tool name (since the actual tool is called in the merge.shscript, where you can switch between any number of merge tool you want)
  • the use of double quotes around $base, $alocal, $remote, $resultwithin the script
  • the conditional path for calling the tool, based on the existence of a "base" file.
  • the need to always have 3 files to merge as parameters (even when 'base' does not exist...)
  • 使用PWD在合并的配置
  • 使用“ merge”作为 merge.tool 名称的名称(因为实际工具在merge.sh脚本中被调用,您可以在其中切换任意数量的合并工具)
  • 在脚本中使用双引号将$base, $alocal, $remote,括起来$result
  • 调用工具的条件路径,基于“基本”文件的存在。
  • 需要始终将 3 个文件合并为参数(即使“base”不存在...)


Just tested it (it turns out, you can download and install only p4merge-- section Client/Visual Merge Tool --, even if you do not have any other P4 product installed).

刚刚对其进行了测试(结果证明,即使您没有安装任何其他 P4 产品,您也只能下载并安装 p4merge-- 部分 Client/Visual Merge Tool --)。

With the settings describe above, MSysGit1.6.3, DOS session or Git bash session:
It just worksTM.

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



Update msysgit 1.7.x

更新msysgit 1.7.x

Benjolmentions in the comments:

Benjol在评论中提到:

p4merge is now supported natively by msysgit.

This means you can just do:

p4merge 现在由 msysgit 原生支持

这意味着你可以这样做:

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