MacHg icon

Merging Branches

When you have multiple branches of work in a repository, you can merge the branches to bring them back together. For more on branching concepts see this.

To merge two branches:

  1. In the sidebar select the repository in which you want to perform the merge, and switch to the History view.

  2. Select a version - the merge base - which you want to merge into.

  3. Select the menu item Repository > Merge...

  4. In the dialog choose the revision which you want to be merged into the merge base.

  5. If needed, choose any advanced options which are appropriate when merging (for example, the --force option to force a merge with outstanding changes).

  6. Click the Merge button for Mercurial to start the merge.

  7. In the process of Mercurial merging files, merge conflicts may arise. To resolve the conflicts between such files, Mercurial will open two such conflicting files in FileMerge. Working in FileMerge, you then need to choose which parts of the two files you want to make up the final merged file. (You can perform edits in the third combined pane below.) When you have finished merging these two files in FileMerge, you must save and quit FileMerge. You will have to repeat this process for any other pairs of conflicting files to be merged.

  8. Finally, switch to the main Browser View, review the merged files, and then choose Action > "Commit Merged Files..." to finish the merge.


Related Topics

Push changes in your Repository to other Repositories

Pull changes from other Repositories into your Repository

External Links

Branching in Mercurial

MDG: Merging work