Advanced History Inspection
Git history can be queried in many ways. git log --author, --grep, --since, path filters, and graph formatting allow you to locate specific changes. git blame identifies the commit associated with each line of a file and can be useful when investigating historical decisions.
Use Blame for Context, Not Blame
git blame is most useful for finding the commit and author associated with a line so you can inspect the surrounding historical context.
Search Git History
git log --oneline --all --grep="authentication"
git log --author="Suriya" --oneline
git log -- src/auth.js
git blame src/auth.js💡 These commands search commit messages, filter by author, restrict history to a file, and attribute lines to historical commits.
Key Takeaways
- Git log can filter history by author, message, date, and path.
git blameis a historical attribution tool.- Inspect the associated commit to understand why a line was introduced.
Knowledge Check
What is `git blame` primarily used for?