How to use FileMerge with Git as a Diff Tool on OSX

How to use FileMerge with Git as a Diff Tool on OSX

As I’m migrating from Subversion brainwaves I’ve been slowly adapting my workflow into Git’s. Problem was i was finding it hard to double check changes in my working folder to that of what was previously committed. In other words I missed the love of FileMerge.

So I began puttering around on the internet and found people writing scripts for git’s external diff editor. But they were missing one important element, the location of OpenDiff to save to! So I did this:

Firstly we need to make the script that git will run when it runs it’s diff. To do this run:

vi ~/

Then we will drop some script in here which basically routes the diff statements generated by Git to the OpenDiff application

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

Notice the “ -merge "$1"” this is the destination to save to. Before hand with other people’s code you would have to manually select the save path. But i did a man opendiff on it to realise all it was, was setting the merge path!

Anyhow. Save that via pressing “ shift + ZZ” Saved! Next we need to make that file executable via “ chmod +x

All that is left is to tell Git to use this script as it’s diff editor, which will then invoke the FileMerge (OpenDiff) program. To do that type in:

git config --global diff.external ~/

Now how i check my staged files with the previous commit would be:

git diff --cached

Which would then open up all the staged files and allow me to choose which one i wanted to keep or not 😀

Posted by voidet

Categorised under Programming
Bookmark the permalink or leave a trackback.


  1. Nice, simple and effective!

    Thanks for a great post.

    February 17, 2010 @ 6:00 pm
  2. Thank you, thank you, thank you

    March 17, 2010 @ 8:09 am
  3. Thanks! This was really helpful! I modified your code to use TextWrangler as the diff tool instead:

    June 10, 2010 @ 7:10 pm
  4. Thank you for sharing, it seems interesting.

    November 3, 2010 @ 4:53 pm
  5. Holy crap that was easy. Thanks!

    June 14, 2011 @ 11:52 pm
  6. the script isn’t necessary — simply invoke git mergetool, optionally with -y.

    August 13, 2011 @ 2:16 am
  7. Thanks! It worked perfectly!!!

    December 29, 2011 @ 5:41 pm

One Trackback

  1. By amychr on April 5, 2012 at 12:20 pm

    […] how to use FileMerge as a difftool with GIT Like this:LikeBe the first to like this post. 22 October 2011 by amychr Categories: tumblr, Uncategorized | Tags: git | Leave a comment […]

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">