Posted by & filed under GIT, OS X.

Are you unhappy with the command line diff tools provided by git? If so, this tutorial is for you.

FileMerge is a utility that comes with OS X / Xcode, although it is hidden and not the easiest to get to. You can dig around the directory until you find it, although the command ‘opendiff’ should already exist in your terminal. To see a visual diff of two files, run ‘opendiff file1 file2’ in your terminal, and a GUI app will appear.

To set FileMerge as your git diff tool, first create a simple script that will be the translator between git and the FileMerge utility. I keep mine in the following location:

vim ~/bin/

The contents of the file will look like this:

/usr/bin/opendiff "$2" "$5" -merge "$1"

Once the script has been made, you’ll want it to be executable

chmod u+x ~/bin/

Finally, tell git that you want to set it up as your default merge tool:

git config --global diff.external ~/bin/

If you later decide you hate it, run this command to go back:

git config --global --unset diff.external

Thomas Hunter II

Thomas is passionate about technology and building products. A web design business created while attending college slowly evolved into a brick and mortar on Main St. of his small Midwestern hometown. His desire for fame and fortune led to the co-founding of a Y Combinator startup and a life in California.
Hey there! I'm currently writing a book on Microservices which I expect to release in early 2017. If you're interested in getting updates please signup here. More info about the Book
  • Max

    Highly useful. I used to use meld for this but this is a good replacement if the meld package is brokens in macports.