Git diff with line numbers (Git log with line numbers) -


when git diff or git log -p, how line numbers of source file(s) inlined output?

i tried man git-diff | grep "line numbers" , tried googling got nothing quickly.

you can't human-readable line numbers git diff

there aren't options line-numbers displayed vertically on side git diff.

unified-diff format

that information available in (c)hunk headers each change in diff though, it's in unified-diff format:

@@ -start,count +start,count @@ 

the original state of file represented -, , new state represented + (they don't mean additions , deletions in hunk header. start represents starting line number of each version of file, , count represents how many lines included, starting start point.

example

diff --git a/osx/.gitconfig b/osx/.gitconfig index 4fd8f04..fcd220c 100644 --- a/osx/.gitconfig +++ b/osx/.gitconfig @@ -11,7 +11,7 @@ <== here!  [color "branch"]         upstream = cyan  [color "diff"] -       meta = yellow +       meta = cyan         plain = white dim         old = red bold         new = green bold 

the hunk header

@@ -11,7 +11,7 @@ 

says previous version of file starts @ line 11, , includes 7 lines:

11  [color "branch"] 12         upstream = cyan 13  [color "diff"] 14 -       meta = yellow 14 +       meta = cyan 15         plain = white dim 16         old = red bold 17         new = green bold 

while next version of file starts @ line 11, , includes 7 lines.

unified-diff format isn't human consumption

as can tell, unified-diff format doesn't make easy figure out line numbers (at least if you're not machine). if want line numbers can read, you'll need use diffing tool display them you.

additional reading


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -