How do I view 'git diff' output with my preferred diff tool/ viewer?

后端 未结 26 1872
清酒与你
清酒与你 2020-11-22 03:20

When I type git diff, I want to view the output with my visual diff tool of choice (SourceGear \"diffmerge\" on Windows). How do I configure git to do this?

26条回答
  •  情深已故
    2020-11-22 03:53

    I tried the fancy stuff here (with tkdiff) and nothing worked for me. So I wrote the following script, tkgitdiff. It does what I need it to do.

    $ cat tkgitdiff
    #!/bin/sh
    
    #
    # tkdiff for git.
    # Gives you the diff between HEAD and the current state of your file.
    #
    
    newfile=$1
    git diff HEAD -- $newfile > /tmp/patch.dat
    cp $newfile /tmp
    savedPWD=$PWD
    cd /tmp
    patch -R $newfile < patch.dat
    cd $savedPWD
    tkdiff /tmp/$newfile $newfile
    

提交回复
热议问题