THE GITHTML FIELD GUIDE
Two dots vs three dots in Git log and diff
In git log, A..B selects commits reachable from B but not A, while A...B selects commits unique to either side. In git diff, two endpoints compare their snapshots, and A...B compares the merge base with B. The same punctuation serves different purposes, so always interpret it together with the command.
Ask about commits or file content
Log operates on sets of commits. Diff compares content between snapshots. Confusion arises when a remembered range rule is transferred from one command to the other. A log range can tell you which commits are exclusive to a branch, while a diff can tell you how two snapshots differ without listing the commits that produced them.
Imagine main and feature diverged from a common commit. A two-endpoint diff includes differences caused by changes on either tip. A three-dot diff focuses on the feature tip relative to the shared base when feature is the second argument. Reversing the arguments changes that focus. This is useful for proposed-change review, but it is not a simulated merge result.
Compare the views on known references
The example assumes main and feature/search exist locally. Inspect their identities first if the repository uses other names. Adding --left-right to a three-dot log makes the two exclusive commit sets easier to distinguish. The stat views keep the initial output compact; inspect full patches once you identify the relevant comparison.
- Use the two-endpoint diff when you want the actual difference between the current snapshots, such as investigating why two branches build differently.
- Use the merge-base comparison when asking what a topic branch introduced since its common history with the base, while remembering it does not resolve future merge conflicts.
git log --oneline main..feature/search
git log --left-right --oneline main...feature/search
git diff --stat main feature/search
git diff --stat main...feature/searchRecord endpoints when sharing findings
Branch names can move after a fetch or a teammate’s push. For a reproducible review, record the commit identifiers behind both endpoints and identify which command produced the comparison. Saying that two branches differ is less useful than specifying whether you inspected exclusive commits, tip-to-tip content, or changes from their merge base.
If the histories have no common ancestor or your shallow clone lacks it, a three-dot comparison may fail or lack the context you expect. Investigate the history boundary rather than changing punctuation until something prints. For complex histories, inspect the merge base explicitly and explain the chosen comparison in your review note. The correct syntax is the one that matches the question, not whichever produces the smallest patch.
Keep remote freshness separate from range syntax. A correct comparison against an old origin/main still answers a question about stale local knowledge rather than the current server branch.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.