How to get git diff with full context?

This seems to work pretty nicely:

git diff --no-prefix -U1000

With the caveat:

The -U flag specifies lines of context. You might need to increase this if there are more than 1000 lines between your changes.


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.


Note: git1.8.1rc1 announce (December 8th, 2012) includes:

A new configuration variable "diff.context" can be used to give the default number of context lines in the patch output, to override the hardcoded default of 3 lines.

so that could help, here, generate a more complete context.

Tags:

Git

Diff

Git Diff