-
-
Save gwarnes-mdsol/b0aff96fbb7a4c92e570e7b03daa7e1b to your computer and use it in GitHub Desktop.
Use 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 | |
# | |
# A git difftool for Mac OS X that uses FileMerge from XCode | |
# | |
# source: https://gist.github.com/gwarnes-mdsol/b0aff96fbb7a4c92e570e7b03daa7e1b | |
# | |
# Setup: | |
# | |
# 1. Copy this file to a known path, e.g. $HOME/bin/gdiff | |
# 2. Make the file executable: | |
# chmod +x $HOME/bin/gdiff | |
# 2. Tell git to use this script as the preferred difftool: | |
# git config --global diff.tool $HOME/bin/gdiff | |
# | |
# Usage: | |
# | |
# git difftool <git diff arguments> | |
# | |
# 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 terminations to issues with git temp files | |
open -a FileMerge -n -W --args -left "$1" -right "$2" -merge "$dir" ${@:2} | |
# references: | |
# http://hints.macworld.com/article.php?story=20070220223441729 | |
# https://gist.github.com/bkeating/329690 | |
# https://gist.github.com/miner/e73fc98a83a8fe05d9ef000d46d68a9f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This version adds support for passing additional command line arguments, such as a branch specification:
and provides information on how to configure it to be used by default.