Three-Way Merge¶
Pro feature
Three-Way Merge is available on Pro and Pro licences. Activate your licence to unlock it.
What three-way merge is¶
When two branches of a repository have both modified the same file independently, a standard two-way comparison cannot determine which side's changes to keep - it can only show that the two versions differ. A three-way merge resolves this by bringing in the base version (the common ancestor) and comparing each branch's changes against it.
Regions that only one side changed are resolved automatically. Regions where both sides changed the same lines relative to the base are conflicts - they require a human decision.
To use three-way merge directly from Git via git mergetool, see Git Integration.
Opening the three-way merge editor¶
- Open a new tab and switch to the Three-Way Merge tab type using the tab type selector.
- Three path bars appear, labelled Base, Left, and Right.
- Set each path to the appropriate file version:
- Base - the common ancestor (the version before either branch made changes)
- Left - your branch's version
- Right - the incoming branch's version
- The editor loads all three files and computes the merge automatically.
Reading the view¶
The editor shows three panels side by side.
- The center panel displays the base version.
- The left panel displays your branch's version.
- The right panel displays the incoming branch's version.
Conflict regions are highlighted distinctly from non-conflicting changes. A conflict region means both Left and Right modified the same lines relative to Base. Non-conflicting changes - where only one side diverged from Base - are shown as resolved automatically and appear in the output without action required.
Accepting changes¶
For each conflict region, you choose which version to keep:
- Click Accept Left to take the left side's version of that region.
- Click Accept Right to take the right side's version of that region.
You can also edit the resolved output directly in the output panel if neither side's version is exactly what you need.
Work through each conflict region from top to bottom. The conflict counter in the toolbar shows how many unresolved conflicts remain.
The resolved output panel¶
Below (or alongside, depending on your layout) the three-way view is the output panel. It shows the merged result as it currently stands. Accepted regions appear with their chosen content. Unresolved conflicts are marked with a placeholder until you accept one side.
You can edit the output panel directly at any point. Manual edits are tracked in the same undo history as accept operations.
Saving the output¶
When all conflicts are resolved, press Ctrl+S to save the output. Diffract writes the merged result to the path shown in the output panel's path bar.
Set the output path to the working copy of the file you want to update (typically the Left or Right path, or a dedicated merge output path).