bashintermediate

Git Blame — Ignore Formatting Commits

Configure git blame to skip formatting-only commits using .git-blame-ignore-revs for cleaner history.

bash
# Create .git-blame-ignore-revs in repo root
cat > .git-blame-ignore-revs << 'EOF'
# Prettier migration — bulk reformat
abc1234abc1234abc1234abc1234abc1234abc1234

# ESLint auto-fix pass
def5678def5678def5678def5678def5678def5678

# Rename files to kebab-case
ghi9012ghi9012ghi9012ghi9012ghi9012ghi9012
EOF

# Configure git to use this file automatically
git config blame.ignoreRevsFile .git-blame-ignore-revs

# Now git blame skips those commits:
git blame src/app.ts
# Shows the actual authorship, not the reformatter

# Blame with specific ignore file (one-off)
git blame --ignore-revs-file .git-blame-ignore-revs src/app.ts

# Blame showing email instead of name
git blame -e src/app.ts

# Blame specific line range
git blame -L 10,20 src/app.ts

# Blame with commit date
git blame --date=short src/app.ts

# Find when a line was deleted (reverse blame)
git log -S 'deletedFunction' --oneline -- src/app.ts

Use Cases

  • Ignoring bulk formatting commits in blame output
  • Accurate code ownership tracking
  • Onboarding — understanding who wrote what

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.