Search code examples
gitdiffgit-diff

How do I get git diff with full context?


How do I create a patch with full context?

I tried --unified=2000, which gives 2000 lines of context:

git diff --unified=2000 branch master --no-prefix > patch

How do I include all the lines in the file without having to specify the maximum number of lines?


Solution

  • I know this is old, but I also dislike hard-coded solutions, so I tested this:

    git diff -U$(wc -l MYFILE)
    

    Using -U seems to be the only way to approach the issue, but using a line count promises that it will work for even a small change in a very large file.