16

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

Analogous to grep -A3 -B5 ...

Mureinik
  • 297,002
  • 52
  • 306
  • 350
Bharat Pahalwani
  • 1,404
  • 3
  • 25
  • 40

2 Answers2

11

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.
larsks
  • 277,717
  • 41
  • 399
  • 399
  • 3
    Note the question suggested different before/after line counts (`-A3 -B5`) and `-U` doesn't support that. – Mu Mind Feb 16 '17 at 06:33
9

You can use the -U switch to control the number of lines of context around the diff:

$ git diff -U5
Mureinik
  • 297,002
  • 52
  • 306
  • 350