Skip to content
Latchkey

git blame: Usage, Options & Common CI Errors

git blame annotates every line of a file with the commit that last touched it.

Blame answers "who changed this line and when". It needs full history, so shallow clones break it.

What it does

git blame walks history to attribute each line of a file to the commit, author, and time that last modified it.

Common usage

Terminal
git blame file.txt
git blame -L 10,20 file.txt       # only lines 10-20
git blame -C -C file.txt          # detect moved/copied lines
git blame <rev> -- file.txt       # blame as of a revision

Options

FlagWhat it does
-L <start>,<end>Limit to a line range
-C / -MDetect copied / moved lines
-wIgnore whitespace changes
--since=<date>Limit how far back to look
-e / --show-emailShow author email instead of name

Common errors in CI

On a shallow clone, blame shows the boundary commit (often the single fetched commit) for most lines because the deeper history is missing. Set fetch-depth: 0 (or git fetch --unshallow) so blame can attribute lines correctly.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →