Progress:
TIER 2 · MODULE 14· Intermediate

git blame

Who broke this and when. Be kind in the comments.

🎯 What & why

git blame shows who last touched each line and in which commit — the first stop when you need to ask why does this line exist? before you ask who do I yell at?

🧠 Mental model

A reverse history walk per line: for every line in the current file, Git follows it backwards through diffs until it finds the commit that introduced it (optionally chasing through renames, moves, and copies).

🛠️ Synopsis

git blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-e] [-p] [-w]
          [--incremental] [-L <range>] [-S <revs-file>]
          [-M[<num>]] [-C[<num>]] [-C] [-C]
          [--since=<date>] [--ignore-rev <rev>]
          [--ignore-revs-file <file>] [--color-lines] [--color-by-age]
          [<rev> | --contents <file> | --reverse <rev>..<rev>]
          [--] <file>

🎚️ Switches & options

FlagWhat it does
`-L <start>,<end>`Restrict to a line range. Accepts :funcname and regex forms — -L :main:src/app.c.
`-w`Ignore whitespace when comparing — kills noise from reindents.
`-M`Detect moved lines within the same file.
`-C`Detect lines copied from other files in the same commit. Repeat -C -C to search across all files in the commit; -C -C -C searches the whole tree.
`--show-email` / `-e`Show committer email instead of name.
`--ignore-rev <rev>`Skip a specific commit (e.g. a mass-format commit) so blame walks past it.
`--ignore-revs-file <file>`Read multiple revs to ignore from a file — typically .git-blame-ignore-revs.
`-p` / `--porcelain`Machine-readable output for tooling.

💡 Use cases

🧪 Examples

Blame a function
git blame -L :handle_request:server.py
Ignore whitespace and moves
git blame -w -M src/parser.c
Show emails for lines 10-30
git blame -e -L 10,30 README.md
Honour the ignore-revs file
git blame --ignore-revs-file .git-blame-ignore-revs app.js

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.