SVN merge help: Created branch within a trunk
Long story short, I essentially created a branch of development within our trunk.
About two weeks ago I decided it would make sense to create a separate branch in our repository, as we're finally making the switch to visual studio 2010. I didn't read as much of the subversion book as I should have.
Here's the basic structure:
REPO/
Installer/
Utilities/
Main/
Upgrade/
Installer/
Utilities/
Main/
Where upgrade is the branch I've created. There've been some modifications in Main, and whole bunch of tree and file modifications within upgrade. What's the best strategy for merg开发者_StackOverflow社区ing this cleanly?
Thanks so much!Hey, actually this is a bad practice to create a branch within trunk, but since this is done, there is a way to merge the code...
Do not merge the complete trees, rather merge the individual folders.
Eg;
If you need to merge back the branch into trunk,
1. Merge the REPO/Installer
directory with REPO/Installer/Upgrade/Installer
In this case, take a local checkout of the complete tree on your local system, and then go to the destination directory (where all the code is to be merged), in this case REPO/Installer/Upgrade/Installer
Either use TortoiseSVN or merge by command line - svn merge http://svn.example.com/repos/REPO/Installer
Once this activity is complete, I would suggest you to move the Branch to a separate location using svn move
. This can be done harmlessly while preserving all the history.
You can update your branch multiple times with the changes from the trunk. And it is as easy as running a merge command.
Steps
- Check out a copy for your branch.
- If you already have a copy of your branch downloaded, then make sure to submit whatever pending items you have in it.
- The update your branch to the head revision (
svn update -r HEAD
) just to ensure consistency. Then merge your changes from the trunk into your branch:
svn merge http://svn.example.com/repos/trunk
Running the command above will simply download the modifications from the trunk into your sandbox. There you can review them, resolve any conflicts, and when ready....
- Commit the modifications into your branch.
Up to this point, you branch is in synch with the trunk.
On the other hand, if what you want is to update the trunk with modifications from the branch, then you must be really careful. This is called a reintegration, and can only be done once. That is, once you reintegrate your branch to the trunk, you will not be able to run this process again.
Steps
- Check out a copy of your trunk.
- If you already have a copy of the trunk in your sandbox ensure to submit whatever pending changes you have.
- Synchronize your branch to the latest changes from your trunk as explained in other recipe above.
- Ensure to update to the latest head revision (
svn update -r HEAD
). Then reintegrate the branch into the trunk:
svn merge --reintegrate http://svn.example.com/repos/my-branch
Running the command above will simply download the modifications to your sandbox. There you can review them, resolve any conflicts, and when ready....
- Commit the modifications in your trunk.
Up to this point, you trunk is in synch with your branch, but your branch is useless, you might just as well delete it. If you want to continue working in branch, you will have to create a new branch for this matter.
If you do not intend to invalidate your branch, then your only solution is to create patch files with the differences and ensure both code bases are equal or manually copy the modifications.
精彩评论