gitvisual-studiovisual-studio-2015p4merge

How to set up p4merge as diff tool for Visual Studio 2015 | git


I've managed to successfully wire up P4Merge with TortoiseGit through this tutorial.

However, given I'm spending most of my time in the IDE (Visual Studio 2015), I'd like to also set this one up to use P4Merge as a diff tool.

Previously (aka while working with TFS), this would be enough. However, given I'm now using git, there's no option in VS to wire it up this way:

enter image description here

However, I found out how to Configure User Tools through the Visual Studio 2015 Tools Developer Command Prompt and tf diff /configure, proceeded as in the previous tutorial with the .bat files, but it doesn't seem to do anything for me.

I'm probably missing something, but hoping that given how popular P4Merge, VS (& git) are nowadays, there have to be people who've managed to already achieve this by now.


Solution

  • I am assuming that you have P4Merge installed in the default install directory, if not edit the directory accordingly in the commands listed below.

    Execute these commands in the command line to set Git's default mergetool and difftool to 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"
    

    After that, whenever git difftool is launched it will start p4merge.

    However, it can still be that on the repository level there is still a setting that overrides the global settings, this is located in .git/config You can manually edit the config file, or you can open up a command line, change directory into the repository and change the default merge and difftool with the following commands.

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