There are two types of model merge that can be used to merge two selected project versions (source and target):
- 3-way merge
- 2-way merge
3-way merge
The 3-way merge allows merging both local and server projects. To merge two selected project versions, the common ancestor (a common project version for both target and source) is used. The common ancestor is calculated automatically when working with Teamwork Cloud projects; however, you have to select a correct common ancestor manually for local and Teamwork Server projects. This is the recommended way to merge project versions because the 3-way merge is able to identify the changes made in the source and target project versions separately by comparing changes between the ancestor and both contributors. This allows merging the selected project versions more smoothly.
Visual representation of the 3-way merge
2-way merge
The 2-way merge compares two local or Teamwork Server project versions selected by the user. Typically, the target version of the project is considered to be the common ancestor (a common project version for both target and source). As a result, only the differences between the source and the target project versions are identified.
Visual representation of the 2-way merge
Merge in Teamwork Cloud
The 3-way merge is the default method used to merge the selected Teamwork Cloud projects; the correct common ancestor version is specified automatically and there is no need to select one manually.
This is how the common ancestor is calculated:
- The lowest version of the trunk from which a branch was created is considered the common ancestor version of the projects being merged. It contains the latest changes both from the source and the target project (version #2 in the image below). Once the correct common ancestor for the two selected project versions is calculated, a merge dialog is opened. In the merge dialog, you can review changes and accept/reject them. When you are finished, click Finish Merge and commit the changes to Teamwork Cloud. A new version (version #6 in the image below) is created.
Automatic common ancestor calculation in Teamwork Cloud
Repetitive merge
When two selected branches are merged more than once (i.e., it is not the first merge in the project), the common version traversing graph nodes up the history tree for both source and target project versions is considered the common ancestor. The diagram below shows how version #2 during the first merge and version #4 during the second merge are common ancestors:
Automatic common ancestor calculation when there are repetitive merges
Set as latest
If an earlier version of the project was set to the latest version in the target branch, e.g., version #8 was reverted to version #7 (version #9 was created), the common ancestor is calculated taking the version that was set as the latest (version #7). In case there is a preceding merge (version #3 is merged with version #4), the source version from the last merge (version #3) is considered the common ancestor; however, if no merges precede the version that was set as the latest, the version the branch splits off the trunk (version #1) is considered the common ancestor.