Git History Research
Use these commands to understand the history and context of code changes.
Common Commands
bash
# See who changed what in a file git blame <file> # Recent commits touching a file git log --oneline -20 -- <file> # Search for when a term was added/removed git log --all -S "search term" --oneline # Show details of a specific commit git show <commit> # Find commits by message content git log --grep="search term" --oneline # Show diff for a specific commit git diff <commit>^ <commit>
Investigation Patterns
- •Why was this code added? - Use
git blamethengit show <commit>to see the full context - •When did this break? - Use
git log -Sto find when the problematic code was introduced - •What else changed together? - Use
git show <commit>to see all files in that commit - •Who should I ask? - Use
git blameto find the author