Using p4merge as a git diff tool

I am using windows 7 . I want to use p4merge as a Git diff / merge tool. I follow this article and this to configure and configure 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" 

And these lines are taken from 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 

The git mergetool command now works fine. But when I use the git difftool in git bash , I expect p4merge but see an internal diff implementation in git bash .

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

Remarks:

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

+6
source share
2 answers

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

You can determine if this is the case by running git difftool --tool-help . It will list the available tools that Git can use (because they found them in your %PATH% ), and the tools that it could use (if they were installed).

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

After this is done, you need the following configuration file to be in your .gitconfig

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

and nothing more. So remove other things like difftool.path and all that.

Then just use git difftool or git mergetool .

Note : I had a repository in which even if I had executed git difftool or git mergetool P4Merge would not start. I'm not sure what the problem was in this repo. However, I tried to create an empty repository somewhere on my disk using git init , add a file, commit it, then modify it, then I tried to use difftool and it worked. So, if the above description does not work for you, most likely the problem is different. Hope this helps.

+2
source

Better late than never:)

mergetool.p4merge.path should be mergetool.p4merge.cmd

Change the path to cmd for mergetool and diffftool lines.

0
source