svn - merge trunk changes into branch and then put branch changes back into the trunk
I am using SVN 1.6 and tortoise client. Iam new to this.
I have a trunk where main production code is kept.
I created a branch "devBranch" from the "trunk"
For past month or so I did check ins in "Dev branch" while many check ins were done in the "trunk"
My development is now complete and I Want to test my version with all the "trunk" changes since I branched off.
I dont want to put my changes in the "trunk" until I have completely tested my code with the changes made in the "trunk"
Once I test the merged version and all the testing is done, I then want to put all my changes in the "trunk" for production QA and release.
How do I go about doing this step by step please.
Answers (1)
This is covered in detail in the freely available and very readable "SVN Book"; specifically, the section on "reintegrating a branch".
In short, you have three phases:
- Create the branch from a certain point on the trunk, and starting making changes.
- Since this is a "feature" branch, and is considered "ahead of" trunk (I use the mnemonic "feature is future" to remind people of this; a "release branch" on the other hand is behind trunk, and merges go the other way), regularly merge everything that's happening on trunk onto the branch. The more frequently you do this, the less time you have to spend sorting out conflicts when you're ready to reintegrate.
- Once you have tested your changes - including the way they interact with changes merged "forward" from trunk, you use the special "reintegrate merge" command to merge to trunk from your branch. Since the branch already contains everything that's happened on trunk (if it doesn't, SVN will abort the merge) this basically overwrites trunk with the branch. You should then delete the branch, as this command cannot be run twice.
Note that in newer versions of SVN, the last step is an automatic mode of the normal "merge" command, and can be repeated multiple times, because the algorithms for storing and interpreting merge info have been improved.
The guide linked above is written with the base SVN tools in mind (i.e. the command-line interface). The same functionality is also available in TortoiseSVN, as documented here. Basically:
- To open the merge wizard, right-click on your checkout of the target folder, then enter the source in the "merge from" box on the second page of the wizard. It requires the full URL; the easiest way to get that is to right-click your checkout of the source folder, select Properties, and look at the top of the Subversion tab.
- Normal merges (trunk to feature branch) are the first option, "Merge a range of revisions".
- Reintegrate merges are the third option.
- Most of the options can just be left at default.