Read the DAG. Customize the output until it tells you what you need.
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.
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.
git log [<options>] [<revision range>] [[--] <path>...]| Flag | What it does |
|---|---|
--oneline | One line per commit — short SHA + subject. |
--graph | ASCII art of the DAG. Combine with --oneline --decorate --all. |
--decorate | Show ref names (branches, tags) next to commits. |
--all | Walk every ref, not just HEAD. |
-p, --patch | Show 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>. |
$ git log --oneline --graph --decorate --all$ git log -S 'TODO: rewrite' --oneline$ git log --follow -- src/main.c$ git log --since=1.week --author=alice --onelineglog='git log --oneline --graph --decorate --all'. You'll thank yourself.-S and -G — they're the fastest way to find a change you remember the content of.--all, log only walks reachable from HEAD. Branches you haven't checked out are invisible.--follow only works with a single path. Multi-file rename tracing isn't supported.Hit each option, then Check answers. Score is recorded; Next is always open.