Blame
In one line
Git blame shows the commit and author for each line of a file — it answers 'who wrote this line and when?'
In simple words
git blame <file> shows each line of the file annotated with the commit hash, author, and date of the last change to that line. It is the "who wrote this code" tool.
Blame is useful for understanding code history: finding who to ask about a confusing line, seeing when a bug was introduced, or understanding the age of code. Despite the name, it is not about assigning blame — it is about understanding context.
Use git blame -L 10,20 <file> to blame only lines 10-20. Many editors and GitHub integrate blame inline, showing annotations next to each line. The alias git annotate does the same thing with a friendlier name.
Example
# Blame a file
git blame app.js
# abc1234 (Alice 2024-01-15 10:00:00) const port = 3000;
# def5678 (Bob 2024-02-20 14:30:00) const host = 'localhost';
# Blame specific lines
git blame -L 10,20 app.jsblame shows the commit, author, and date for each line.
Related terms
Related Resources
Related Lessons
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.