Skip to content

Instantly share code, notes, and snippets.

@magoon
Last active December 22, 2015 22:29
Show Gist options
  • Save magoon/6540733 to your computer and use it in GitHub Desktop.
Save magoon/6540733 to your computer and use it in GitHub Desktop.
p4merge is a free visual diff tool for Mac OS X that can be used as a git mergetool. This allows you to resolve some more complicated merge conflicts. Here is a quick getting started guide.
# Use p4merge as a mergetool for visually resolving Git merge conflicts
# by adding these lines to ~/.gitconfig
[merge]
conflictstyle = diff3
tool = p4merge
[mergetool "p4merge"]
cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "$PWD/$BASE" "$PWD/$REMOTE" "$PWD/$LOCAL" "$PWD/$MERGED"
trustExitCode = false
[mergetool]
prompt = false
keepBackup = false
# Download p4merge (free) from http://cdist2.perforce.com/perforce/r14.1/bin.macosx106x86/P4V.dmg
# To resolve a merge conflict, type:
# git mergetool [filespec]
# To see changes in a common diff, type:
# git diff --staged
# To back out a merge attempt:
# git merge --abort
# To remove any dirt left behind
# git clean -f --dryrun
# then remove the --dryrun if all looks legit.
# Crash course in p4merge:
# As you scroll down, you'll see three shapes to the right of each hunk in the bottom output pane.
# Shapes correspond to LOCAL (current branch), REMOTE (what you're merging in), and BASE (common ancestor).
# Click a shape to toggle inclusion in the bottom output pane.
# Only light up ONE of the shapes!
# If you're backmerging master into a feature branch, you'll probably prefer REMOTE before BASE before LOCAL.
# When done, save and exit, then git will recognize what you've saved. You can git diff --staged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment