First Contact: Understanding Any Codebase FastLesson 1.4
How to use git log and git blame to understand code history
git log flags, git blame output, commit message quality, finding when a bug was introduced, git bisect overview, reading diffs
Code Has a Timeline — Read It
Every line of code was written at a specific moment, for a reason. git log and git blame let you recover that context. They're the fastest way to answer "why does this exist?"
git log: Project History at a Glance
# See recent commits with author and message
git log --oneline -20
# See commits that touched a specific file
git log --oneline -- src/auth/login.js
# See full diff for a specific commit
git show a3f9c12git blame: Who Wrote This Line and When
# See who last changed each line of a file
git blame src/auth/login.js
# Output format:
# a3f9c12 (Jane Doe 2023-11-04) const validateToken = (token) => {
# Ignore whitespace-only changes
git blame -w src/auth/login.jsReading the Output
Each blame line shows: commit hash, author name, date, and the code. Click the hash in a GitHub/GitLab UI to see the full PR and discussion — that's where the real reasoning lives. A commit message like fix: handle null token in validateToken — closes #412 tells you a bug existed, what it was, and where the ticket is. Cryptic messages like update are a warning sign about team practices.
