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

喜欢而已 提交于 2019-11-29 21:55:40

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 ...

jonalv

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...

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

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.

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 ....

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

Rob Wilkerson

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!