Using git difftool to view differences in entire directory

746 views Asked by At

I'm having trouble trying to use git difftool (in this case, opendiff for mac) to visualise the differences made in the latest git commit. I don't want to launch opendiff for each pair of files that has changed, I just want to launch one instance of opendiff which compares the entire directory, so I've followed the advice from this answer which is to use --dir-diff. I ended up using this command:

git difftool HEAD^ HEAD --dir-diff

The problem is that when I launch this command, the opendiff says that there are 0 differences (even though using normal diff will show differences in multiple files). What's going on? How do I use difftool correctly?

1

There are 1 answers

0
Steven Kramer On

The files get deleted immediately because opendiff (the command line tool) exits straight after launching FileMerge (the GUI tool). You need to write a short wrapper script that will copy the left and right folders to (another) temp location and start opendiff with those locations.

Edit: you can configure a custom difftool that will start FileMerge directly and wait for it to exit. Add this to your ~/.gitconfig

[difftool "fm"]
cmd = /Applications/Xcode.app/Contents/Applications/FileMerge.app/Contents/MacOS/FileMerge -left \"$LOCAL\" -right \"$REMOTE\"
path =