
Distributed version control is great for merging. Things like bazaar, git, mercurial, etc. all have sophisticated tools and good support for merging branches of the same code that have diverged even if files have been moved or renamed. But what about merging branches with no common ancestor? I needed to do just that today. I had two bazaar repositories that were separate parts of the same project. One repository was the client and one held the server. I decided that it was pretty inconvenient and a bad idea to have them in separate repositories. I wanted to merge the repositories so I wouldn't lose the history for either project.
Turns out this is pretty easy... In bazaar you can simply do the following:
- Change directory to the destination working copy.
- Execute the following command
bzr merge /path/to/source-working-copy -r0..-1
- Note the -r0..-1 part of the command. This tells bazaar to merge a range of revisions from the first revision to the most current.
- Now review and commit the changes. Notice that bazaar gives you an indication that all history is preserved by displaying a list of checkin comments. Nice.
3 comments:
thank you!
Very simple (and therefore good) howto :)
I have a problem with subdirectories:
I have multiple directories containing plain branches, let's call them C:\bazaar\A, C:\bazaar\B and so on.
Creating a new branch to merge them all into, at
C:\combined, I want to have C:\combined\A, C:\combined\B and so on. But when I use bzr merge, from a freshly created directory C:\combined\A, the content of C:\bazaar\A is merged into C:\combined, not C:\combined\A. Any ideas? Thanks!
This is awesome! I have several repositories that I want to merge as sub directories of a larger repository, without losing any history.
Thanks!
Post a Comment