Last active
October 26, 2022 18:29
-
-
Save miner/e73fc98a83a8fe05d9ef000d46d68a9f to your computer and use it in GitHub Desktop.
using FileMerge as git difftool on Mac OS X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# my git difftool, calls FileMerge with project as -merge target | |
# better than using opendiff | |
# | |
# cd to your project dir and and run difftool like this: | |
# git difftool -d -x gdiff | |
# find top level of git project | |
dir=$PWD | |
until [ -e "$dir/.git" ]; do | |
if [ "$dir" == "/" ]; then | |
echo "Not a git repository" >&2 | |
exit 1; | |
fi | |
dir=`dirname "$dir"` | |
done | |
# open fresh FileMerge and wait for termination, avoids issues with git temp files | |
open -a FileMerge -n -W --args -left "$1" -right "$2" -merge "$dir" | |
# references: | |
# http://hints.macworld.com/article.php?story=20070220223441729 | |
# https://gist.github.com/bkeating/329690 |
Thank you for sharing this! I was struggling with how to get git directory diffs with FileMerge - this is the only solution I have seen that works reliably.
I've made a couple enhancements to this gist at https://gist.github.com/gwarnes-mdsol/b0aff96fbb7a4c92e570e7b03daa7e1b. To get a diff do:
git diff -r 9607ab015c6c39f9b77a8564126a23e74c890dcd
(Won't it be nice when github allows gist pull requests!)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By the way, FileMerge comes with the Xcode tools. Get Xcode from https://developer.apple.com/xcode/downloads/