Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mikemichaelis/4f6d62a03300a24e97c1d19b9413371e to your computer and use it in GitHub Desktop.
Save mikemichaelis/4f6d62a03300a24e97c1d19b9413371e to your computer and use it in GitHub Desktop.
Setup p4merge as git mergetool in Windows (cmd & PS)
git config --global merge.tool p4merge
git config --global mergetool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"
@AlexByte
Copy link

AlexByte commented May 6, 2017

I don't like tabs order REMOTE, BASE, LOCAL. It's better to use
git config --global mergetoll.p4merge.cmd "'C:/Program Files/Perforce/p4merge.exe' $BASE $LOCAL $REMOTE $MERGED"

@ziriax
Copy link

ziriax commented Feb 26, 2018

The above code has a small typo, the copy/paste-able lines should be:

git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd "'C:/Program Files/Perforce/p4merge.exe' $BASE $LOCAL $REMOTE $MERGED"

@808codist
Copy link

This is what worked for me, as entered in Git Bash:

git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd "'C:/Program Files/Perforce/p4merge.exe' \$BASE \$LOCAL \$REMOTE \$MERGED"

1st command is same as others.

For the 2nd command, the \ before each $ prevents bash from trying to treat the last 4 arguments as environment variables.

@daveamol
Copy link

This is what worked for me, as entered in Git Bash:

git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd "'C:/Program Files/Perforce/p4merge.exe' \$BASE \$LOCAL \$REMOTE \$MERGED"

1st command is same as others.

For the 2nd command, the \ before each $ prevents bash from trying to treat the last 4 arguments as environment variables.

Finally. I was trying to figure out howto get it to work for cmder. This works perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment