Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Xcode 4 as Git difftool

I want to use Xcode 4's "Version Editor" view as my standard difftool for Git.

In other words, I want to be able to set this option:

git config --global diff.external <XCODE>

And have the diff open in Xcode's diff viewer (because it's cool).

Is this possible? How?

like image 521
andrhamm Avatar asked Nov 16 '11 16:11

andrhamm


1 Answers

Sadly not possible. Here's hoping Apple changes that someday though.

I'm guessing you already know the following, but for the benefit of others who may not, you can use Apple's FileMerge application instead for a similar, albeit somewhat lesser, experience with a command like:

git difftool path/to/file

My git defaults to using FileMerge as the difftool, but you can configure it explicitly with:

git config --global diff.tool opendiff

(This stops git from listing the candidate tools every time too.) I also like to disable git's difftool pre-launch prompting:

git config --global difftool.prompt false

It is possible to configure git so that git diff will invoke FileMerge as well, or instead. (I prefer to just leave git diff the way it is myself.) If you want that you first need to create a shell script to map the appropriate arguments to opendiff:

#!/bin/sh
/usr/bin/opendiff "$2" "$5" -merge "$1"

and then run

git config --global diff.external /path/to/shell/script
like image 97
sjs Avatar answered Sep 28 '22 02:09

sjs