How to Find Who Changed a Line With git blame

git blame annotates every line of a file with the commit and author that last modified it.

Published September 28, 2026

git blame shows, for every line of a file, the commit and author that last modified it. It helps you understand why a line exists.

How it works

Output includes the short hash, author and date per line. Follow up with git show <hash> to read the commit.

Use -L to limit to a range and -w to ignore whitespace-only changes.

Try it

git blame -L 10,12 app.js
a1b2c3d (Ada 2026-03-01) const x = 1
d4e5f6a (Bob 2026-04-02) const y = 2

Practical examples

Blame a file

git blame src/app.js

Limit lines

git blame -L 40,60 src/app.js

Ignore whitespace

git blame -w src/app.js

Read the commit

git show a1b2c3d

Common mistakes

  • Using blame to assign fault instead of understanding.
  • Stopping at a formatting-only commit.
  • Forgetting to follow moved code with -M and -C.

Key takeaways

  • blame = last change per line.
  • Combine with git show.
  • -L limits the range.

FAQ

Can I ignore a formatting commit?

Yes with --ignore-rev or .git-blame-ignore-revs.

GUI alternative?

IDEs and GitHub show blame inline.

More Git articles