- 1 Minute to read
- Print
- DarkLight
- PDF
Two-dot diff `..` vs three-dot diff `...`
- 1 Minute to read
- Print
- DarkLight
- PDF
Background
AllSpice.io offers both two-dot ..
and three-dot …
diffs. By default, Design Reviews (aka PRs) start with a three-dot …
diff.
You can see which comparison is being made in the URL:https://hub.allspice.io/AllSpice-demos/Altium-archimajor-3d-printer-driver-demo/compare/main...develop
vshttps://hub.allspice.io/AllSpice-demos/Altium-archimajor-3d-printer-driver-demo/compare/main..develop
You can click on the …
or ..
to switch between the modes.
High-Level Explanation
Two-Dot (..
) Comparison:
What it shows: Changes that occurred on the second branch (or commit) since it diverged from the first.
Use case: When you want to see what has been added to the second branch compared to the first.
Three-Dot (...
) Comparison:
What it shows: Changes that occurred on both branches since they diverged from their common ancestor.
Use case: When you want to understand the differences between two branches in the context of their shared history.
Medium-Level Explanation
Two-Dot (..
) Comparison:
This compares the end points of two branches. It shows the commits that are present in the second branch but not in the first. If you think of it as "Branch1..Branch2", it essentially answers the question, "What changes are in Branch2 that were not in Branch1 when Branch2 was created?"
Three-Dot (...
) Comparison:
This is more nuanced. It shows everything that is different between the two branches' latest commits but excludes anything they both inherited from a common ancestor. So, it's useful for understanding what each branch has introduced since they diverged, not just what the second branch added.
Low-Level (Detailed) Explanation
Two-Dot (..
) Comparison:
Syntax:
git diff Branch1..Branch2
When you use this comparison, Git resolves it as "find the common ancestor of Branch1 and Branch2, and compare it with the tip of Branch2". It's a direct comparison that tells you, "If I merge Branch2 into Branch1, these are the changes that will be applied". It does not concern itself with any changes that might have been made on Branch1 after the branches diverged.
Three-Dot (...
) Comparison:
Syntax:
git diff Branch1...Branch2
This comparison is more about understanding the divergence between two branches. Git finds the common ancestor of both branches and then shows you the changes from that common ancestor to each branch tip. It's essentially saying, "These are the changes that have occurred in both branches since they started to differ from each other". This is particularly useful for reviewing or auditing the history before merging, as it shows what each branch has contributed uniquely since their paths diverged.
Understanding these differences can greatly enhance your Git workflow, especially when reviewing changes or preparing to merge branches.