Git Blaming Only show certain lines


Output can be restricted by specifying line ranges as

git blame -L <start>,<end>

Where <start> and <end> can be:

  • line number

    git blame -L 10,30

  • /regex/

    git blame -L /void main/, git blame -L 46,/void foo/

  • +offset, -offset (only for <end>)

    git blame -L 108,+30, git blame -L 215,-15

Multiple line ranges can be specified, and overlapping ranges are allowed.

git blame -L 10,30 -L 12,80 -L 120,+10 -L ^/void main/,+40