There is a super simple way to set up git to use opendiff or p4merge as the diff tool:
git config --global alias.diffy 'difftool -t opendiff -y'
git config --global alias.diffp 'difftool -t p4merge -y'
after we do that, in the future, we can use
git diffy # to use opendiff
git diffp # to use p4merge
Alternatively, Bash or Zsh aliases can be used:
alias gitd='git difftool -t opendiff -y'
alias gitd2='git difftool -t p4merge -y'
To see what diff tools can be used:
git difftool --tool-help
Details:
There are methods to set up git diff to use Xcode's FileMerge, or opendiff, or to use Perforce's p4merge. Usually the method is to set up an external shell script, and then set the diff.external to use that script.
The command git difftool, can readily perform the task without needing any external scripts. An extra advantage is, we can use opendiff or p4merge without altering diff.external
Note that when we use p4merge, we will need to add it to our path, which, for example, is /Applications/p4merge.app/Contents/MacOS on the Mac.
Top comments (0)