Git diff only show context above diff (like grep -A0 -B5)

Viewed 64

git diff has the -U / --unified option that

Generate diffs with <n> lines of context instead of the usual three

Questions regarding this option have been asked multiple times:


However, none of those questions, nor the man page, mention any way of changing the context depending on the direction.

For example, has the following 'context control options':

After:   -A NUM  --after-context=NUM
Before:  -B NUM  --before-context=NUM
Around:  -C NUM  --context=NUM

So I can use seq 1 10 | grep 5 -A0 -B10 to only get the context above the matching line, in this example it will output row 1 - 5


Question:

How can I extend my git diff command to only show the <n> lines above the diff?

0 Answers
Related