Progress:
TIER 3 · MODULE 38· Expert

git rev-list

Engine behind git log, cherry, bisect — the DAG walker.

🎯 What & why

git rev-list is the DAG walker that powers log, cherry, bisect, and most history-aware plumbing. If you script anything about commits, you reach for it.

🧠 Mental model

Give it a set of tips and exclusions; it emits commit SHAs in topo order. log is rev-list with formatting bolted on - rev-list is the engine, not the UI.

🛠️ Synopsis

git rev-list [<options>] <commit>... [-- <path>...]

  A..B          # commits reachable from B but not A
  A...B         # symmetric difference
  ^A B          # B minus A (same as A..B for two refs)
  --count       # just print the number
  --objects     # also list trees and blobs reachable

🎚️ Switches & options

FlagWhat it does
<commit>...Tip commits to walk from
^<commit>Exclude this commit and its ancestors from the walk
--max-count=<n>Stop after n commits
--reverseOutput oldest-first instead of newest-first
--first-parentFollow only the first parent of merges (linearize)
--no-mergesSkip merge commits
--ancestry-pathOnly commits on a path between two endpoints
--bisectPick the midpoint commit (used by git bisect)
--countPrint the count instead of the SHAs
--objectsAlso emit referenced tree and blob SHAs
--pretty[=<fmt>]Format each commit (turns rev-list into log)

💡 Use cases

🧪 Examples

Ahead/behind count
git rev-list --left-right --count main...origin/main
Linear mainline only
git rev-list --first-parent --no-merges main
All reachable objects
git rev-list --objects --all | head
Oldest-first replay list
git rev-list --reverse main..feature

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

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