Module 5: Inspecting and Repairing History

Reading Logs and File History

Reading logs and file history

Git history is useful only if you know how to read it. Start with concise logs, then add detail when you need it.

git log --oneline
git log --oneline --decorate --graph --all
git show HEAD

git show displays one commit with its metadata and diff. Replace HEAD with any commit hash.

File-specific history

git log -- README.md
git log -p -- README.md
git blame README.md

git blame shows the last commit that changed each line. Use it to find context, not to assign fault. Follow up with git show to understand the complete commit.

Searching history

git log --grep="payment"
git log -S"function_name" -- path/to/file

These commands help answer when a behavior appeared, where a line came from, or why an implementation changed.