P4Merge as a git mergetool and difftool on Linux

Sadly, no Sourcetree for Linux. Console it is. Not for merging though. P4Merge.


Download P4Merge, extract the archive and create a link (somewhere in your $PATH).

sudo tar \
    --no-same-owner \
    --extract --ungzip \
    --file ~/Downloads/p4v.tgz \
    --directory /opt
sudo ln \
    --symbolic \
    /opt/p4v-2014.2.951414/bin/p4merge \

--no-same-owner ensures the files are owned by the current user (root) and not by whomever created the original archive.

--directory /opt sets the destination (installation) directory for p4v.


Edit your ∼/.gitconfig file:

        tool = p4merge
[mergetool "p4merge"]
        cmd = p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
        trustExitCode = true


Edit your ∼/.gitconfig file:

        tool = p4merge
[difftool "p4merge"]
        cmd = p4merge "$LOCAL" "$REMOTE"

Nice to have

This has nothing to do with p4merge, but it makes the git mergetool and git difftool commands a bit more usable from the console by not asking stupid questions and creating sissy backup files.

Edit your ∼/.gitconfig file:

        prompt = false
        keepBackup = false
        keepTemporaries = false
        prompt = false