Skip to main content
Back to command reference
Inspecting History

git blame

Find out who last modified every line of a file

Practical example

bash
git blame src/index.ts              # annotate every line
git blame -L 15,30 src/app.ts   # lines 15-30 only
git blame -w -C src/index.ts    # ignore whitespace, detect moved lines

Command overview & how it works

Annotates each line of a file with the commit hash, author name, and timestamp of the most recent modification. This is the go-to command when you need to understand why a particular line of code exists — it tells you who wrote it, when, and in which commit. Use git blame -L 10,20 file.ts to limit output to a specific line range, or git blame -w to ignore whitespace changes. Use git blame -C to detect lines that were copied from other files (even within different files in the same commit). Combined with git show <hash>, you can trace any line of code back to its original context, commit message, and related changes. This is especially useful during debugging, code review, and refactoring legacy code.

Chapter 08 · History & Diff Mastery

Master Git log, diff, and blame offline

Read advanced graph traversals, patch analysis, and investigation workflows in the 97-page offline course — ₹499.

Learn more

Practical tips

  • Pair git blame with git show <hash> to read the commit message behind a line of code.
  • Limit output to the lines you care about with git blame -L 10,30 file.ts.
  • Use -w to ignore whitespace-only changes and -C to follow lines that moved between files.

Deep-dive guides & tutorials

In-depth walkthroughs and practical scenarios related to git blame

All guides →

Related commands

More from Inspecting History