Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Git diff and merge with p4merge (OSX)
[merge]
keepBackup = false
tool = p4merge
[mergetool "p4merge"]
cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$REMOTE\"" "\"$PWD/$LOCAL\"" "\"$PWD/$MERGED\""
keepTemporaries = false
trustExitCode = false
keepBackup = false
[diff]
tool = p4merge
[difftool "p4merge"]
cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$REMOTE\"" "\"$LOCAL\""
@samsalisbury

This comment has been minimized.

Copy link
Owner Author

@samsalisbury samsalisbury commented Apr 22, 2013

  1. Install p4merge from perforce.com
  2. Put the following bits in your ~/.gitconfig, and then you can do $ git mergetool and $ git difftool to use p4merge
  3. Note that $ git diff will still just use the default inline diff viewer :)
    (tested with git version 1.8.2)
@daniloakamine

This comment has been minimized.

Copy link

@daniloakamine daniloakamine commented Feb 28, 2014

Thanks for the helpful tip!

@King-Wizard

This comment has been minimized.

Copy link

@King-Wizard King-Wizard commented Aug 13, 2015

Works like a charm, Thanks a lot.

Note: you could also disable the prompting for every file, adding these two lines below to ~/.gitconfig will do the trick:

[difftool]
        prompt = false
@ahammond

This comment has been minimized.

Copy link

@ahammond ahammond commented Dec 16, 2015

I think you have remote and local mixed up. I swapped them and it looks more like what I'd expect in p4merge:

cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$LOCAL\""  "\"$PWD/$REMOTE\"" "\"$PWD/$MERGED\""   
@andrescardona

This comment has been minimized.

Copy link

@andrescardona andrescardona commented Feb 12, 2016

Thank you very much, works great!

@BeginMan

This comment has been minimized.

Copy link

@BeginMan BeginMan commented May 20, 2016

Thank a lot.

@samiraguiar

This comment has been minimized.

Copy link

@samiraguiar samiraguiar commented Jul 29, 2016

Awesome, thanks!

@eric-holmberg

This comment has been minimized.

Copy link

@eric-holmberg eric-holmberg commented Sep 23, 2016

very nice! thx

@jeff303

This comment has been minimized.

Copy link

@jeff303 jeff303 commented May 10, 2017

Anybody else getting a segmentation fault when attempting to run launchp4merge? Configured exactly the same as described above. Running simply p4merge (under /Contents/MacOS in the app package) seems to work fine. OS X 10.12.4, P4merge MACOSX1011X86_64/2017.1/1491634

@luckylooke

This comment has been minimized.

Copy link

@luckylooke luckylooke commented Jul 10, 2017

Thank you @samsalisbury for sharing, and also thanks @kingWizard for useful flag. I am adding the usual path for global .gitconfig which is suprisingly ~/.gitconfig, maybe it will save a bit of googling :)

@mpern

This comment has been minimized.

Copy link

@mpern mpern commented Oct 6, 2017

@jeff303 googling for the same issue led me to your comment.

It looks like launchp4merge does not like running witout any arguments.
If I run launchp4merge to diff two files and just close the diff window, everything is fine. (even Cmd-Q works)

If I run launchp4merge without any arguments and also don't choose any files to diff after it launches, then a segfault happens.

@johny-gog

This comment has been minimized.

Copy link

@johny-gog johny-gog commented Nov 4, 2018

It stopped working on MacOS Mojave for me :( Please help.

p4merge just opens without files chosen.

@UnreachableCode

This comment has been minimized.

Copy link

@UnreachableCode UnreachableCode commented Aug 8, 2019

I am also getting the segmentation fault issue on Mojave 10.14.5.

@StanislavMayorov

This comment has been minimized.

Copy link

@StanislavMayorov StanislavMayorov commented Mar 10, 2020

It still works with P4Merge/2019.2/1904275. Config should be updated like jeff303 said.

[merge]
  keepBackup = false
	tool = p4merge
[mergetool "p4merge"]
	cmd = /Applications/p4merge.app/Contents/MacOS/p4merge "\"$PWD/$BASE\"" "\"$PWD/$REMOTE\"" "\"$PWD/$LOCAL\"" "\"$PWD/$MERGED\""
	keepTemporaries = false
	trustExitCode = false
	keepBackup = false
[diff]
    tool = p4merge
[difftool "p4merge"]
	cmd = /Applications/p4merge.app/Contents/MacOS/p4merge "\"$REMOTE\"" "\"$LOCAL\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.