DEV Community

Jonathan Flower
Jonathan Flower

Posted on

How To merge tool with p4 merge

Download and install p4merge

Setup p4merge as a visual mergetool

$ git config --global merge.tool p4mergetool 
$ git config --global mergetool.p4mergetool.cmd \ "/Applications/p4merge.app/Contents/MacOS/p4merge \$PWD/\$BASE \$PWD/\$REMOTE \$PWD/\$LOCAL \$PWD/\$MERGED" 
$ git config --global mergetool.p4mergetool.trustExitCode false 
$ git config --global mergetool.keepBackup false
Enter fullscreen mode Exit fullscreen mode

Using p4merge to resolve conflicts

When you run into a conflict when merging simply run:

$ git mergetool

  • You will be prompted to run "p4mergetool", hit enter and the visual merge editor will launch.
  • Using the merge tool you can resolve the conflict and then save the file.
  • After you exit the next file with a merge conflict will open. Or it there are none, you will see the terminal.

You can also configure p4merge as a visual diff tool

git config --global diff.tool p4mergetool
git config --global difftool.p4mergetool.cmd \ "/Applications/p4merge.app/Contents/MacOS/p4merge \$LOCAL \$REMOTE"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)