Progress:
TIER 1 · MODULE 08· Basics

git log

Read the DAG. Customize the output until it tells you what you need.

🎯 What & why

Walk the commit DAG starting at HEAD (or any ref), printing each commit's metadata. Every other history-reading question — who, when, between what, since when — boils down to a flag on log.

🧠 Mental model

log is a frontend to rev-list (the DAG walker) plus a formatter. It walks parent pointers backward from a starting point until it runs out of commits or hits a stop condition. Branches are names, not lines on a graph.

🛠️ Synopsis

git log [<options>] [<revision range>] [[--] <path>...]

🎚️ Switches & options

FlagWhat it does
--onelineOne line per commit — short SHA + subject.
--graphASCII art of the DAG. Combine with --oneline --decorate --all.
--decorateShow ref names (branches, tags) next to commits.
--allWalk every ref, not just HEAD.
-p, --patchShow the diff for each commit.
-S<string>Pickaxe — find commits that added/removed <string>.
-G<regex>Like -S but a regex against the diff text.
--author=<pat>Filter by author. --committer=<pat> for committer.
--since=, --until=Time-bound the walk.
-- <path>Limit to commits that touched <path>.

💡 Use cases

🧪 Examples

The log most people want.
$ git log --oneline --graph --decorate --all
Find when a string was introduced or removed.
$ git log -S 'TODO: rewrite' --oneline
History of one file across renames.
$ git log --follow -- src/main.c
Last week's commits by Alice.
$ git log --since=1.week --author=alice --oneline

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.