How to get git diff with full context?

前端 未结 6 823
暗喜
暗喜 2021-01-30 07:48

How to create patch suitable for reviewing in crucible?

git diff branch master --no-prefix > patch

This generates only 3 lines of context. S

6条回答
  •  Happy的楠姐
    2021-01-30 08:30

    Got inspiration and so I added a git alias.

    $ cat ~/.gitconfig | fgrep diff
            df = "!git diff -U$(wc -l \"$1\" | cut -d ' ' -f 1) \"$1\""
    $ git df 
    

    Update:

    Just found "git df" does not work sometimes, due to directory change when executing git alias. (See git aliases operate in the wrong directory). So this is the updated version:

    $ cat ~/.gitconfig | fgrep df
            df = "! [ \"$GIT_PREFIX\" != \"\" ] && cd \"$GIT_PREFIX\"; ~/bin/git_df.sh"
    $ 
    $ cat ~/bin/git_df.sh
    #!/bin/bash
    for FILE in $@; do
        git diff -U$(wc -l "${FILE}" | cut -d ' ' -f 1) "${FILE}"
    done
    exit 0
    

提交回复
热议问题