If you like me use a Linux station to do your development and don't want to use the standard Git diff tool this Gist is for you.
- Download installation from Perforce Web Site
https://www.perforce.com/downloads/visual-merge-tool
Or download via command line:
$ curl https://cdist2.perforce.com/perforce/r19.1/bin.linux26x86_64/p4v.tgz -o p4v.tgz
- Unpack on a directory of your choice
$ sudo mkdir -p /opt/p4merge
$ sudo tar -zxvf p4v.tgz -C /opt/p4merge --strip-components=1
- Add the directory from p4merge binaries on you PATH variable changing the file ~/.profile:
$ vi ~/.profile
...
export PATH=$PATH:/opt/p4merge/bin
...
- Update your environment variables:
$ source ~/.profile
Alternatively you can create a symbolic link inside a directory that alreadly setted on PATH variable of your system, for example:
$ sudo ln -s /opt/p4merge/bin/p4merge /usr/local/bin/p4merge
- Configure your git client to use P4Merge as your diff and merge tool
$ vi ~/.gitconfig
...
[merge]
# Change to true if you wish to keep a backup of the files that was merged
keepBackup = false;
tool = p4merge
[mergetool]
prompt = false
[mergetool "p4merge"]
cmd = p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
keepTemporaries = false
trustExitCode = false
keepBackup = false
[diff]
tool = p4merge
[difftool]
prompt = false
[difftool "p4merge"]
cmd = p4merge "$LOCAL" "$REMOTE"
keepTemporaries = false
trustExitCode = false
keepBackup = false
...
- To verify run
$ git difftool
Enjoy!