How to control the number of lines that surround each difference when running `git diff`?

Depending on what I am diff ing, sometimes I want to see several lines (say 10) above and below the + - deletions, sometimes I just want to see a couple of lines surrounding them.

Is there a way to tell git the line number it should show me?

+6
source share
2 answers

You can choose -U . On the man page:

-U<n>, --unified=<n>

Create diff with context lines instead of the usual three. Implies -p.

+10
source

git diff -U<num> . The default value is 3.

+4
source

Source: https://habr.com/ru/post/901176/


All Articles