How to use git blame to find who changed a line

· Category: Git

Short answer

git blame <file> shows the commit and author for each line in the file.

Steps

  1. Blame a file:
git blame src/app.py
  1. Blame specific lines:
git blame -L 10,20 src/app.py
  1. Ignore whitespace changes:
git blame -w src/app.py
  1. Show email instead of name:
git blame -e src/app.py

Tips

  • Use with git show <commit> to see the full change context.
  • git blame on renamed files works with -C and -M options.
  • IDE integrations often provide blame annotations inline.

Common issues

  • Large refactoring commits make blame less useful; use -C to detect moved lines.
  • Blame shows the last change, not every historical change to that line.