Search code examples
gitgit-diff

change no of lines after and before in git diff output


I want to increase the number of lines displayed before and after changes in git diff output.

Analogous to grep -A3 -B5 ...


Solution

  • According to git diff --help, git diff supports the same arguments as the standard diff command w/r/t context:

       -U<n>, --unified=<n>
           Generate diffs with <n> lines of context instead of the usual three. Implies
           -p.