bashintermediate
Git Blame Investigation Techniques
Use git blame and related tools to trace code authorship and understand change history.
bashPress ⌘/Ctrl + Shift + C to copy
# Basic blame — show who changed each line
git blame src/lib/registry.ts
# Blame with line range
git blame -L 10,30 src/lib/registry.ts
# Ignore whitespace changes
git blame -w src/lib/registry.ts
# Show original author (ignore moved/copied lines)
git blame -M src/lib/registry.ts # detect moves within file
git blame -C src/lib/registry.ts # detect moves from other files
git blame -CCC src/lib/registry.ts # aggressive copy detection
# Show email instead of name
git blame --show-email src/lib/registry.ts
# Blame at a specific commit
git blame abc1234 -- src/lib/registry.ts
# Find when a line was deleted
git log -S "deleted function name" --oneline
# Find when a line was added/removed with regex
git log -G "pattern" --oneline
# Show the commit that introduced a line
git log -1 abc1234
git show abc1234
# GUI blame
git gui blame src/lib/registry.ts
# List files changed by author
git log --author="Alice" --name-only --pretty=format: | sort -uUse Cases
- Finding who introduced a bug
- Understanding code history and context
- Tracing when a specific change was made
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
bashintermediate
Squash Multiple Git Commits
Interactive rebase to squash multiple commits into one clean commit before merging a feature branch.
Best for: Cleaning up messy commit history
#git#squash
bashadvanced
Git Interactive Rebase Guide
Interactive rebase to reorder, edit, drop, and squash commits for a clean Git history.
Best for: Crafting a clean commit history before merge
#git#rebase
bashadvanced
Git Bisect to Find a Bug
Use binary search through commit history with git bisect to find the exact commit that introduced a bug.
Best for: Finding which commit introduced a regression
#git#bisect
bashbeginner
Git Log Formatting Tricks
Custom git log formats with graphs, filtering by author, date ranges, and file changes.
Best for: Reviewing project history efficiently
#git#log