Differences between revisions 4 and 5
Revision 4 as of 2009-05-19 19:30:58
Size: 1376
Editor: localhost
Comment: converted to 1.6 markup
Revision 5 as of 2011-10-02 22:45:29
Size: 1481
Editor: mpm
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
/!\ Merging unrelated histories will generally result in an incoherent history and is not recommended

/!\ Merging unrelated histories will generally result in an incoherent history and is not recommended

To merge two unrelated repositories, preserving history, follow these steps.

 hg clone REPO1 work         # First pull from both repos...
 cd work
 hg pull -f REPO2
 hg merge                    # Then simply merge.
 hg commit

You can keep pulling changes from both repositories in the future, if you like.

On the other hand, if you're doing this in order to stop using two separate repositories, just hg push REPO1 and you're finished.

Filtering. If you only want to merge certain files or directories from REPO2 into REPO1, you can use the ConvertExtension to create a repository with only the files from REPO2 that you want, then treat that as your REPO2 when following the instructions above.

Renaming. Now suppose you want the files from REPO2 to live in a subdirectory of REPO1 called "lib2". Here's how to do that (without using hg convert):

 hg clone REPO1 work         # Again, pull from both repos...
 cd work
 hg pull -f REPO2
 hg update -C tip            # Now update to the REPO2 tip...
 mkdir lib2                  # And rename everything...
 hg rename * lib2
 hg commit -m "Move everything into lib2 directory."
 hg merge                    # Then simply merge.
 hg commit

Again, you can continue to pull changes from both repositories if needed. Or not.


CategoryTipsAndTricks

MergingUnrelatedRepositories (last edited 2011-10-02 22:45:29 by mpm)