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

后端 未结 7 2019
礼貌的吻别
礼貌的吻别 2020-12-23 23:14

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 scrip

相关标签:
7条回答
  • 2020-12-23 23:41

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

    0 讨论(0)
  • 2020-12-23 23:45

    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

    0 讨论(0)
  • 2020-12-23 23:49

    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.

    0 讨论(0)
  • 2020-12-23 23:49

    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.

    0 讨论(0)
  • 2020-12-23 23:52

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

    0 讨论(0)
  • 2020-12-23 23:58

    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
    
    0 讨论(0)
提交回复
热议问题