What is a Three-way Diff?
To summarize: Two-way diffs are for comparing. Three-way diffs are for collaborating.
Let's break this down:
Imagine you and your colleague, Sam, are editing a document. You have your original version, and Sam has made some changes to their copy.
Next station: Wimbledon
Next station: Wimbledon Park
When we compare these two versions, it's called a two-way diff:
Next station: Wimbledon Park
This two-way diff works well for identifying differences between known document versions. However, it doesn't tell us who made each change: Have you removed the word "Park", or has Sam added it? With many changes in a document, this quickly gets confusing.
To collaborate effectively, we need a way to attribute each change to an author. That's where three-way diff comes in.
Let's say you created the first document draft and shared it with Sam before both of you edited it.
In the three-way diff, we have three document versions:
- The original version you started with (the "base").
Next station: Wimbledon Park
you - Your version with your changes (the "local").
Next station: Wimbledon
you - Sam's version with their changes (the "remote").
Next station: Wimbledon Park
Sam
Intuitively, you may already notice that this indicates you removed the word 'Park', while Sam did not add it.
By comparing these three versions, we can see who made each change and how they contribute to the final document.
This attribution is crucial for effective collaboration.
Exactly this author attribution is created for every change when you send all three documents, the "base", your "local", Sam's "remote", to a tool like TreeDiff with three-way comparison capabilities.
In short, two-way diff is for comparing known versions, while three-way diff is for collaborating before creating a final version.
Learn how blacklining and redlining uses two-way diffs and three-way diffs here.
Learn more comparison terminology here.