Git Revision Ranges: Two Dots and Three Dots
Think in sets for history commands
For the chapter graph, the commits reachable from C are A, B, C; from E they are A, B, D, E. For log and rev-list, C..E selects D and E (right-side ancestry minus left-side ancestry). E..C selects C. C...E selects C, D and E (exclusive to either side). Output ordering is separate from membership; our deterministic fixture uses equal timestamps, so compare sets.
git log --format=%s C..Egit log --format=%s E..Cgit rev-list --left-right --count C...EDiff uses endpoints, not sets
For diff, C..E compares the snapshots at C and E. It includes removal of light.txt (only at C) and topic changes. C...E instead compares B, their unique merge base, with E. It does not show the main-only light.txt removal. E...C compares B with C. The right operand matters; this is not a symmetric comparison. Multiple possible merge bases require extra care; the teaching graph has exactly one.
git diff --name-status C..Egit diff --name-status C...Egit diff --name-status E...CRead advanced set shorthand
A leading ^ excludes a commit and its ancestors in rev-list: E ^C is equivalent to C..E. M^! selects M alone, M^@ expands its parents (so their reachable history is selected), and M^- means M^1..M, selecting M, D and E in this fixture. These forms are useful for inspecting a merge in a history walk; they are not universal diff semantics.
git log --format=%s "M^!"git log --format=%s "M^@"git log --format=%s "M^-"Practice: review a proposal
You want to review topic changes without the main-only light change: use git diff C...E. To count topic-only commits use git rev-list --count C..E; expect 2. To list both sides without common ancestry use C...E with rev-list. Empty endpoints default to HEAD in these forms, but explicit names improve review clarity.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Git Revision Ranges: Two Dots and Three Dots — knowledge check
Predict revision resolution, commit sets and path selection.
Which commits are selected by log C..E?
Which commits are selected by rev-list C...E?
What is the before endpoint of diff C...E?
Which command compares C directly with E?
What does rev-list M^! select?