Git Blame With Line Ranges

Mar 30, 2023

If you have the unfortunate situation of having to deal with really large files and you need the git blame info to find the most recent commit or author then using the line range argument is your friend.

This is supported by the -L option for the blame command and supports a few variations other than just the line number.

Our most common case is looking at a line or range of lines:

git blame -L 100,100 path/to/file

will get the blame info for line 100 in the file. You can also use +/- offsets for the end which is often more useful so the above can be written as

git blame -L 100,+1 path/to/file
git blame -L 100,120 path/to/file

will provide the blame for same for lines 100 through 120, or

git blame -L 100,+20 path/to/file

will do so for lines 100 through 119 (20 lines)

These two options are very fast for limiting the blame info to certain lines instead of processing the entire file. There's also the convenient, but not always so fast option in very large files, option for starting the range with a regex search, for e.g.

git blame -L /funcName/ path/to/file

There's more to this form and the other options over at


Newer: Removing Large Table Data from MySQL/MariaDB dumps

Older: Diffing MySQL/MariaDB Schemas with Basic Tools Quickly