BJ Clark
BJ Clark

Reputation: 3275

How do you make git diff use gitx --diff on OS X

Gitx has a great diff viewer, how do I make git automatically pipe git diff whatever into gitx?

I've tried to set git config diff.external to a shell script that looks like this:

git diff "$2" "$5" | gitx

However, that only opens all the individual files up into multiple gitx windows, and it really messes up the files names (changes them all to tmp files with crazy names).

Does anyone have a better solution?

Upvotes: 13

Views: 11441

Answers (7)

jonalv
jonalv

Reputation: 6116

I am not quite sure this is what you want but for us on Macs it sure is handy anyway and somewhat related, you might want to try:

$ git difftool -t opendiff #hash

That opens the diff in the opendiff program which I find very useful. This is much easier than creating a shell script and forcing all your diffs through the new external diff. If you are not on a Mac you can probably change the opendiff into your favorite available diff tool...

Upvotes: 5

tek_yogi
tek_yogi

Reputation: 121

This question might be a little old, but I just found something that works for me.

Open GitX app(v.7), select "GitX" menu then "Enable Terminal Usage"

At terminal pipe diff to gitx via:

git diff | gitx

Upvotes: 2

Douglas
Douglas

Reputation: 37761

I'm using this script which I have named git-diffx and put in my path:

#!/bin/bash

result=$(git diff $@)

if [ "$result" ]; then
   echo "$result" | gitx
fi

Then instead of git diff ..., you call git diffx ....

Upvotes: 2

Wolfram Kriesing
Wolfram Kriesing

Reputation: 1527

like sigjuice is saying up there. Only that noobs (like i am now) need to know how to "connect" git to use it. Here is what I did

echo 'opendiff $2 $5' > ~/opendiff-git.sh
chmod a+x ~/opendiff-git.sh
git config --global diff.external ~/opendiff-git.sh 

and now all "git diff whatever" should open FileMerge.app ...

Upvotes: 18

Mark
Mark

Reputation: 6128

I did this for Araxis merge, but modifying these basic instructions should not be hard for whatever you perferred tool is.

First I created ~/bin/git-diff-driver.sh and added execute permission to the file.


#!/bin/sh

/usr/local/bin/compare -title1:"$1 (repo version)" -title2:"$1 " -max "$2" "$5"

Araxis installs it's command line interface tools in /usr/local/bin The compare tool is their generic tool and the araxis* tools feed through compare.

Once this is set up the following lines need to be added to ~/.gitconfig


[merge]
    tool = araxismerge
[mergetool "araxismerge"]
    cmd = "/usr/local/bin/compare -3 -merge -wait $LOCAL $BASE $REMOTE $MERGED"
    path = /usr/local/bin/
[diff]
    external = "/Users/mark/bin/git-diff-driver.sh"

This redirects all 2-way and 3-way diffs through Araxis Merge. It seems like the "path =" shouldn't be necessary, but it works.

Good Luck.

Upvotes: 2

Rob Wilkerson
Rob Wilkerson

Reputation: 41236

I asked a similar question a while back. That answer may help you. There are a couple of questions in there, but one has to do with opening a diff view in something other than FileMerge.

Upvotes: 1

sigjuice
sigjuice

Reputation: 29759

I'm sorry this doesn't really answer your question about gitx. I'm not even sure if gitx can function as a generic diff tool. You might like FileMerge, a merge/diff tool included in the Xcode install. There is a script called opendiff that can launch it for you. Simply make a script with the following line in it and point diff.external at it.

opendiff $2 $5

Upvotes: 3

Related Questions