AI Hints
Home›Git & GitHub Tutorial›Tags, Blame and Bisect
Git & GitHub · Lesson 93 of 144

Who Changed This Line?

Git blame.

⏱ 2 min read▶ Video at 1:41:50🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

You find a strange line of code, and wonder, who wrote this, and why? Git blame shows, for every line in a file, the last commit that changed it.

Who Changed This Line?
From the video: Who Changed This Line?
  • A strange line of code
  • Who wrote it? Why?
  • git blame

git blame

Git blame, and the file name. Each line shows the short hash, the author, the date, and then the line itself. The display none line came from commit five a nine a, and so on. Let's look at it with git show. The message says tidy styles. Now we know when it arrived, who to ask, and why.

git
git blame --date=short style.css
ef9c9471 (Sam Lee 2026-01-05 1) body { font-family: sans-serif; }
bed2a1ab (Sam Lee 2026-01-05 2) p { line-height: 1.5; }
3c99ef26 (Sam Lee 2026-01-05 3) a { color: teal; }
5a9a3544 (Sam Lee 2026-01-05 4) body { display: none; }
git show --stat 5a9a354
commit 5a9a3544a95b4dbe964d6c3ed106972a1fd0cdcf
Author: Sam Lee <sam@example.com>
Date:   Mon Jan 5 09:47:57 2026 +0000

    Tidy styles

 style.css | 1 +
 1 file changed, 1 insertion(+)

Not about blaming people

Despite its name, blame isn't about blaming people. It's about context. The commit message, and the pull request it came from, usually explain why a line exists. GitHub has a blame view too, on any file page.

Purposecontext, not blame
Showslast commit per line
Thengit show <hash>
On GitHubBlame button

Summary

Git blame shows which commit last changed each line. Follow up with git show to see why. Next, finding exactly which commit broke something.

Key takeaways
  • git blame <file>
  • One commit per line
  • git show <hash> for why
Next up: Finding a Bug with Bisect — git bisect