foundation

git log

Search and format commit history to understand when, why, and by whom a change entered the repository.

`git log` inspects commit history. Filters and formatting turn a flat list into an investigation tool.

					git log --oneline -20
git log --graph --decorate --all
git log -p -- path/to/file.ts
git log main..feature/login
git log --grep="fix(auth)"
				

Use path filters, ranges (`A..B`), author/date, and graph output to answer: when did this change land, is the fix on main, what merged before the regression?

On interviews: find a change by message or file, compare branches, inspect release history, correlate commits with PR/issue links.

Common pitfalls: reading only the latest commit misses merge context; shallow clones limit history depth; huge default log output without filters.

The trade-off is exhaustive history views versus focused queries that answer one question fast.

Checklist:

  • Filter by path, range, or grep when debugging.
  • Use `--graph` for branch topology.
  • Follow SHAs to `git show` and PR metadata.
  • Combine with diff and blame for full context.