Using Perforce merge tool (p4merge) with git on Cygwin

This guide will show you how to setup the Perforce merge tool (p4merge) as your default git mergetool on Cygwin.

  1. Download the Perforce client (p4v) from here. (Go to Clients > Visual Merge Tool, and download the appropriate installer for your machine)
  2. Perform the installation, making sure that you only check the merge tool component and cross out all other components
  3. (This step is optional)
    Open up cygwin, and create a symlink to p4merge by doing:

    ln -s /cygdrive/c/Program\ Files/Perforce/p4merge.exe /usr/bin/p4merge

    (modify the target path if you installed Perforce in a non-default folder). This way, you can open up p4merge anytime in Cygwin simply by typing “p4merge”

  4. Add the following lines to your ~/.gitconfig in Cygwin using your preferred text editor:

    [merge]
    tool = p4merge
    [mergetool “p4merge”]
    path = c:/Program Files/Perforce/p4merge.exe
    trustExitCode = true

    Again, edit the path if you used a non-default Perforce install path.

  5. Save and exit the file. If you have pending merges in the current git tree and you type git mergetool, voila, your merge will be done using the very user-friendly p4merge.
Advertisements

Tags: , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: