git 中的 p4merge 合并工具出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10742129/
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
error with p4merge merging tool in git
提问by user1415621
I have setup my classpath for p4merge an set the file .gitconfig, but there i get this error when the p4merge tool suppose to opem those two files that are in conflict. anybody knows the solution?
我已经为 p4merge 设置了我的类路径,并设置了文件 .gitconfig,但是当 p4merge 工具假设要操作这两个冲突的文件时,我会收到此错误。有人知道解决方案吗?
added to classpath: "C:\Program Files\Perforce\p4merge.exe" added to .gitconfig file:
添加到类路径:“C:\Program Files\Perforce\p4merge.exe”添加到 .gitconfig 文件:
[merge]
tool = p4merge
[mergetool "p4merge"]
cmd = p4merge.exe \\"$BASE\\" \\"$LOCAL\\" \\"$REMOTE\\" \\"$MERGED\\"
ERROR MESSAGE:
错误信息:
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
回答by Tuan
It works for me:
这个对我有用:
[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
回答by Xelian
Why is everything so hard I hate to write commands so what I did?
为什么我讨厌写命令那么难,所以我做了什么?
- Install p4Merge tool form hereserach for P4Merge and install the exe then you need only
- 在这里安装 p4Merge 工具表单 serach for P4Merge 并安装 exe 然后你只需要
Install it as Windows user
Go into your user direcotry and search for .gitconfigedit it and add
以 Windows 用户身份安装
进入您的用户目录并搜索.gitconfig编辑它并添加
[mergetool "p4merge"] path = C:\Program Files\Perforce\p4merge.exe cmd = \"C:/Program Files/Perforce/p4merge.exe\" "$BASE" "$LOCAL" "$REMOTE" "$MERGED" [merge] tool = p4merge
[mergetool "p4merge"] path = C:\Program Files\Perforce\p4merge.exe cmd = \"C:/Program Files/Perforce/p4merge.exe\" "$BASE" "$LOCAL" "$REMOTE" "$MERGED" [merge] tool = p4merge
How to use it? When you pull something and have conflicts you can just write
如何使用它?当你拉东西并有冲突时,你可以写
git mergetool
git合并工具
And the tool will be open.
并且该工具将被打开。
At the bottom is you final version you can edit there then just save and commit and the conflict will be resolved.
底部是您的最终版本,您可以在那里编辑,然后保存并提交,冲突将得到解决。
回答by michael_hook
You may also need to restart your git console if you've just installed p4merge, for the updated environment variables to register.
如果您刚刚安装了 p4merge,您可能还需要重新启动 git 控制台,以便注册更新的环境变量。
回答by Matthew Harrison
After I installaed P4Merge, I followed the instructions on this page and it works perfectly for me.
安装 P4Merge 后,我按照此页面上的说明进行操作,它非常适合我。
回答by Dan Lister
It looks like it can't find p4merge so try adding "C:\Program Files\Perforce\" to your PATH environment variable via System Properties.
看起来它找不到 p4merge,所以尝试通过系统属性将“C:\Program Files\Perforce\”添加到您的 PATH 环境变量中。
回答by ellotheth
Add the full P4merge path to your .gitconfig. Here's mine (note that the path separators are flipped around, i.e. c:/ instead of c:\):
将完整的 P4merge 路径添加到您的 .gitconfig。这是我的(注意路径分隔符是翻转的,即 c:/ 而不是 c:\):
[merge]
tool = p4
[mergetool "p4"]
cmd = c:/winprogs/p4merge/p4merge.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
回答by patlach
If you don`t want to add p4merge in environmental variable Path (as Dan Lister mentioned) you could add parameter path in your git config:
如果您不想在环境变量 Path(如 Dan Lister 提到的)中添加 p4merge,您可以在您的 git 配置中添加参数 path:
[mergetool "p4merge"]
path = C:/Program Files/Perforce/p4merge.exe
It works for me on git v1.7.11 (WinXP).
它在 git v1.7.11 (WinXP) 上对我有用。
回答by Akhilesh
These steps worked for me.
After downloading and installing P4Merge tool from perforce.com
从 perforce.com 下载并安装 P4Merge 工具后
After your profile name/email id.
在您的个人资料名称/电子邮件 ID 之后。
Replace this content in your ~/.gitconfig file
在您的 ~/.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\""
回答by Ankit Mahajan
Use this for the proper set up as merge tool.
将此用于正确设置为合并工具。
$ 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/\$MERGED"
$ git config --global mergetool.p4mergetool.trustExitCode false
$ git config --global mergetool.keepBackup false
$ 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
Reference: https://gist.github.com/tony4d/3454372
回答by sachyy
1) edit your git config file
1) 编辑你的 git 配置文件
git config --edit --global
2) add following (change accordingly)
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) initialize the config file
3)初始化配置文件
git init
All set, you are ready to go.
一切就绪,您可以开始了。