How to make “git diff” output normal diff format (non-unified, non-context)?

后端 未结 2 1666
陌清茗
陌清茗 2020-12-30 04:55

I want git diff to output normal, plain old diff output (not unified diff, and not context diff).

I want this:

$ diff file1 file2
2c2
&l         


        
2条回答
  •  孤城傲影
    2020-12-30 05:41

    You can use same script (see man git(1) for details):

    $ cat diff.sh
    #!/bin/sh
    # get args: path old-file old-hex old-mode new-file new-hex new-mode
    
    diff "$2" "$5"
    
    return=$?
    if [ $return -le 1 ]; then
        exit 0
    else
        exit $return
    fi
    
    $ GIT_EXTERNAL_DIFF=./diff.sh git diff HEAD^..HEAD
    

提交回复
热议问题