Three-Way File Comparison and Merging

The Professional Edition of Merge enables you to compare and merge three files side-by-side. Note that merging capability is available only for text comparisons and folder comparisons.

  • Three-way file merging is frequently used to merge two derived files into a common-ancestor or base version.
  • The need to do this typically arises when more than one person is working simultaneously on a set of source files stored in a version control or configuration management system.
  • Merge integrates with a number of such configuration management systems. Find out more.
  • Three-way file comparisons can be launched directly from a three-way folder comparison, allowing efficient integration of entire branches of source code.
  • Merge Professional also supports Automatic File Merging, to speed up three-way merges.
  • The Professional Edition even features Automatic Folder Merging, making it possible to perform a quick three-way merge of entire source trees.

A three-way file comparison

Use the Two-way (vertical) and Three-way (vertical) buttons in the ribbon to switch between two-way and three-way comparisons.

Ordering of files within the comparison display

Merge is designed to be most effective when the common ancestor file is used as the centre file of the three files being compared, with the two modified versions on either side. The differences between each of the revisions and the ancestor are clearly displayed in this arrangement.

Using three-way file comparisons

All of the comparison, editing and merging features of two-way file comparisons apply to three-way comparisons. See the related topics below for more information.

Working with the common ancestor file in the middle file panel, you can merge changes from the two derived revisions into it to produce a final merged file. When doing this, it is usually prudent to verify that each and every change is wanted and compatible with the others you have already accepted.

Overlapping changes

Particular care should be taken when merging changes from the two derived revisions that relate to the same section of the ancestor file. These are so-called overlapping changes (sometimes known as conflicting changes) and are clearly indicated in Merge because the linking lines connect the changes from the derived files to the same section of the ancestor file. The in-place editing capability is especially useful in these situations to allow fine-grained modifications to be made.

You can quickly highlight conflicting changes with a red conflict icon by previewing an automatic merge.

Non-overlapping changes

For non-overlapping changes, a single mouse click is usually all that is required to merge a change into the ancestor file. However, even with non-overlapping changes it is important that every one is carefully inspected to ensure it is compatible with the changes from the other derived files. It is not usually safe to assume that changes are compatible merely because they do not textually overlap. This is especially true of program source code.

Automatic merging

Merge provides the ability to merge automatically two derived files into the common ancestor. Although this is a useful feature, care should be taken to ensure that the results of the automatic merge are appropriate.