11

我已经为 p4merge 设置了我的类路径并设置了文件 .gitconfig,但是当 p4merge 工具假设对这两个冲突的文件进行操作时,我得到了这个错误。有人知道解决方案吗?

添加到类路径:“C:\Program Files\Perforce\p4merge.exe”添加到 .gitconfig 文件:

[merge]
    tool = p4merge
[mergetool "p4merge"]
    cmd = p4merge.exe \\\"$BASE\\\" \\\"$LOCAL\\\" \\\"$REMOTE\\\" \\\"$MERGED\\\"

错误信息:

Normal merge conflict for 'protected/views/layouts/main.php':
  {local}: modified file
  {remote}: modified file
Hit return to start merge resolution tool (p4merge):
C:\Program Files (x86)\Git/libexec/git-core/mergetools/p4merge: line 8: p4merge:
 command not found
protected/views/layouts/main.php seems unchanged.
Was the merge successful? [y/n] n
merge of protected/views/layouts/main.php failed
4

10 回答 10

6

这个对我有用:

[merge]
    keepBackup = false;
    tool = p4merge
[mergetool "p4merge"]
    path = C:/Program Files/Perforce/p4merge.exe
    cmd = \"C:/Program Files/Perforce/p4merge.exe\" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
    keepTemporaries = false
    trustExitCode = false
    keepBackup = false
[difftool]
    prompt = false
[mergetool]
    prompt = false
于 2013-09-09T10:33:16.200 回答
4

为什么一切都那么难,我讨厌写命令,所以我做了什么?

  1. 在此处 为 P4Merge安装 p4Merge 工具表格并安装 exe,然后您只需要

在此处输入图像描述

  1. 以 Windows 用户身份安装

  2. 进入您的用户目录并搜索.gitconfig编辑并添加

[mergetool "p4merge"]
  path = C:\\Program Files\\Perforce\\p4merge.exe
  cmd = \"C:/Program Files/Perforce/p4merge.exe\" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
[merge]
  tool = p4merge

如何使用它?当你拉一些东西并发生冲突时,你可以写

git 合并工具

该工具将打开。

在此处输入图像描述

底部是你的最终版本,你可以在那里编辑,然后保存并提交,冲突就会得到解决。

于 2016-11-08T21:23:58.110 回答
3

如果您刚刚安装了 p4merge,您可能还需要重新启动 git 控制台,以便注册更新的环境变量。

于 2012-06-12T16:32:24.897 回答
2

安装 P4Merge 后,我按照此页面上的说明进行操作,它非常适合我。

https://gist.github.com/tony4d/3454372

于 2014-01-31T16:21:04.960 回答
1

It looks like it can't find p4merge so try adding "C:\Program Files\Perforce\" to your PATH environment variable via System Properties.

于 2012-05-24T18:13:26.923 回答
1

如果您不想在环境变量 Path 中添加 p4merge(如 Dan Lister 所述),您可以在 git 配置中添加参数路径:

[mergetool "p4merge"]
    path = C:/Program Files/Perforce/p4merge.exe

它适用于 git v1.7.11 (WinXP)。

于 2013-02-05T14:04:53.053 回答
0

将完整的 P4merge 路径添加到您的 .gitconfig。这是我的(请注意,路径分隔符是翻转的,即 c:/ 而不是 c:\):

[merge]
    tool = p4
[mergetool "p4"]
    cmd = c:/winprogs/p4merge/p4merge.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
于 2012-05-24T19:10:48.803 回答
0
These steps worked for me.

从 perforce.com 下载并安装 P4Merge 工具后

在您的个人资料名称/电子邮件 ID 之后。

在 ~/.gitconfig 文件中替换此内容

 enter code here

[merge]
  keepBackup = false
    tool = p4merge
[mergetool "p4merge"]
    cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$LOCAL\""  "\"$PWD/$REMOTE\"" "\"$PWD/$MERGED\""   
    keepTemporaries = false
    trustExitCode = false
    keepBackup = false
[diff]
    tool = p4merge
[difftool "p4merge"]
    cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$REMOTE\"" "\"$LOCAL\""
于 2017-10-12T18:13:30.553 回答
0

1) 编辑你的 git 配置文件

git config --edit --global

2)添加以下内容(相应更改)

[merge]
    keepBackup = false;
    tool = p4merge
[mergetool "p4merge"]
    path = C:/Program Files/Perforce/p4merge.exe
    cmd = \"C:/Program Files/Perforce/p4merge.exe\" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
    keepTemporaries = false
    trustExitCode = false
    keepBackup = false
[diff]
    tool = p4mergetool
[difftool "p4merge"]
    cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge $LOCAL $REMOTEhere

3)初始化配置文件

git init

一切就绪,您可以出发了。

于 2020-05-28T06:53:28.043 回答
0

将此用于正确设置为合并工具。

  • $ git config --global merge.tool p4mergetool

  • $ git config --global mergetool.p4mergetool.cmd \ "/Applications/p4merge.app/Contents/Resources/launchp4merge \$PWD/\$BASE \$PWD/\$REMOTE \$PWD/\$LOCAL \$PWD/ \$合并"

  • $ git config --global mergetool.p4mergetool.trustExitCode false

  • $ git config --global mergetool.keepBackup false

参考:https ://gist.github.com/tony4d/3454372

于 2019-07-22T21:33:38.600 回答