intermediate

git blame

Find the commit context for a line while using it as investigation data, not as personal attribution.

`git blame` maps each line to the commit that last modified it. Use it to find **context** — why a line exists — not to assign blame to people.

					git blame -L 120,150 src/parser.ts
git blame -w src/parser.ts    # ignore whitespace
git log -L 120,150:src/parser.ts   # line history
				

Follow the blamed commit to its message, PR, tests, and surrounding diff before changing behavior. `.git-blame-ignore-revs` excludes bulk formatting commits.

On interviews: line history vs single blame snapshot, ignore-revs, pairing blame with `git show`.

Common pitfalls: formatting commits obscure original intent; blaming without reading the full commit; using blame on generated files.

The trade-off is quick line attribution versus deeper history tools (`git log -L`) for moved or reformatted code.

Checklist:

  • Use blame as investigation data, not judgment.
  • Inspect the blamed commit's full diff.
  • Configure ignore-revs for mass reformat.
  • Prefer `log -L` when lines moved heavily.