使用p4merge作为git diff工具 [英] Using p4merge as git diff tool

查看:93
本文介绍了使用p4merge作为git diff工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用windows 7.我想使用p4merge作为Git差异/合并工具.我遵循这篇文章设置和配置p4merge:

I use windows 7. I want to use p4merge as Git diff/merge tool. I follow this article and this one to setup and config p4merge:

git config --global merge.tool p4merge
git config --global mergetool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"
git config --global diff.tool p4merge
git config --global difftool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"

这些行来自git config:

merge.tool=p4merge
mergetool.p4merge.path=C:/Program Files/Perforce/p4merge.exe
diff.tool=p4merge
difftool.p4merge.path=C:/Program Files/Perforce/p4merge.exe
mergetool.keeptemporaries=false
mergetool.prompt=false

现在git mergetool命令可以正常工作.但是,当我在git bash中使用git difftool命令时,我希望使用p4merge,但是我看到了git bash中diff的内部实现.

Now git mergetool command works fine. But when I use git difftool command in git bash, I expect p4merge but I see internal implementation of diff in git bash.

我尝试了 Smooth Git + P4merge ,但是它不起作用对我来说,我也尝试按照外部合并和差异工具,但我不明白.

I tried Smooth Git + P4merge but it does not work for me also I tried to do as described in External Merge and Diff Tools but I did not understand that.

注意:

当冲突类型为removed file conflict时,git difftool命令打开p4merge.

When type of conflict is removed file conflict, git difftool command opens p4merge.

推荐答案

不确定是否有帮助,但是最新版本的Git支持P4Merge(我在Windows上通过MSYS2使用git version 2.17.0.).

Not sure if helps, but recent versions of Git support P4Merge (I use git version 2.17.0. on Windows through MSYS2).

可以通过运行git difftool --tool-help来确定是否是这种情况.它会列出Git可以使用的可用工具(因为它们已经在您的%PATH%中找到了)以及它可以使用的工具(如果已安装).

You can tell if this is the case or not by running git difftool --tool-help. It'll list the available tools Git can use (because they've found them in your %PATH%) and the tools it could use (if they were installed).

如果p4merge在此列表中,则只需将p4merge.exe所在的路径添加到您的%PATH%(在Windows上,我建议快速环境编辑器).

If p4merge is in this list then you just need to add the path where p4merge.exe resides to your %PATH% (on Windows I recommend Rapid Environment Editor for this).

完成此操作后,只需在.gitconfig

After this is done you just need the following config to be in your .gitconfig

[diff]
    tool = p4merge
[merge]
    tool = p4merge

,仅此而已.因此,请删除difftool.path之类的所有其他内容.

and nothing else. So remove other stuff like difftool.path and all that.

然后只需使用git difftoolgit mergetool来满足您的需求.

Then just use git difftool or git mergetool to your hearts content.

注意:我有一个存储库,即使我确实发布了P4Merge的git difftoolgit mergetool命令也不会启动.我不确定该回购中的问题是什么.但是,我尝试使用git init在驱动器上的某个位置创建一个空的仓库,添加文件,提交,然后对其进行修改,然后然后我尝试了difftool并成功了.因此,如果上述说明对您不起作用,则可能是问题出在其他地方.希望这会有所帮助.

Note: I had a repository in which even if I did issue the git difftool or git mergetool commands P4Merge wouldn't start. I'm not sure what was the problem in that repo. However I tried creating an empty repo somewhere on my drive with git init, add a file, commit it, then modify it, then I tried difftool and it worked. So if the above description doesn't work for you chances the problem lies somewhere else. Hope this helps.

这篇关于使用p4merge作为git diff工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆