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

Meta: November 16th 2009 // Programming // 397 views

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 ~/git-diff-cmd.sh

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

#!/bin/sh
/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 ~/git-diff-cmd.sh

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 :D

Tags: , , , , , , ,

WeDecal.com

Postscript: Leave A Comment // Subscribe (RSS Feed)

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

// 1 comments so far.

  1. Henke // February 17th 2010

    Nice, simple and effective!

    Thanks for a great post.

Who Are You?

Your Email Address

Your Website

:D :) :o :eek: :( :lol: :wink: :arrow: :idea: :?: :!: :evil: :p

You can follow any responses to this entry via its RSS comments feed. You may also leave a trackback by clicking this link.