Ever wondered who last modified a specific line in a file? The git blame
command helps you track changes, showing who made the change, when, and in which commit.
Basic Usage
To see the history of changes in a file, run:
This shows:
- Commit hash
- Author name
- Timestamp
- Line of code
Example output:
Blame Specific Lines
Check only certain lines (e.g., 10 to 20)
git blame -L 10,20 filename.txt
Avoid unnecessary blame due to formatting:
See Blame Before a Commit
Find how a file looked before a change:
Track Changes Across Renames
If a file was renamed, follow its history:
When to Use git blame
✔ Debugging – Find out who introduced a bug.
✔ Code Reviews – Check recent changes.
✔ Documentation – Ask the right person for help.
⚠ Tip: Use git blame
to learn, not to point fingers!