How to get git diff with full context?

前端 未结 6 756
暗喜
暗喜 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条回答
  •  时光取名叫无心
    2021-01-30 08:33

    Previously accepted solutions don't work for me when viewing a specific file/commit (the -U option seems to mess with rev/path parsing), but --inter-hunk-context= works in this case on git version 2.24.0:

    git diff \
        --no-prefix \
        --inter-hunk-context=2000 \
        master -- \
            path/to/file.py
    

    If you don't know the file size, you can of course find it with wc -l instead of hard-coding it:

    git diff \
        --no-prefix \
        --inter-hunk-context=$(wc -l path/to/file.py) \
        master -- \
            path/to/file.py
    

提交回复
热议问题