Using P4Merge with Git
Should anyone want using P4Merge to compare and merge code in Git, it’s pretty straightforward – just configure it properly.
You have to open Git’s global configuration file (C:\Users\<name>\.gitconfig) and append (or modify) the following sections:
[merge]
tool = p4mergetool
[mergetool "p4mergetool"]
cmd = \"C:\\Program Files\\Perforce\\p4merge.exe\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
[diff]
tool = p4mergetool
[difftool "p4mergetool"]
cmd = \"C:\\Program Files\\Perforce\\p4merge.exe\" \"$LOCAL\" \"$REMOTE\"
[difftool "p4mergetool-merge"]
cmd = \"C:\\Program Files\\Perforce\\p4merge.exe\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
The last entry allows you to perform interactive merge (in which you manually merge all changes) in the following way:
$ git difftool -t p4mergetool-merge <merged branch> HEAD
// Merge files now
$ git commit -m "Merged with branch <merged branch>"
$ git push