Tuesday, November 11, 2008

How to reintegrate SVN branch back to trunk using Tortoise

We've begun in our dev shop to use SVN (Subversion)branches to develop, test and implement new features. Like many shops I've run across, we use Tortoise as our SVN client. I didn't fully understand the process of reintegrating my branch back to the trunk, and after some reading (along with some trial and error), came up with the basic steps to get everything back together.

Now, these steps below do not include manually merging any changes. I was fortunate enough in this first exercise to have auto-merge ability for my changes to shared files and all my other files were new.

(Be sure you have any files saved and closed, like edits in Eclipse.)

1. Commit your branch back to the repo.
2. IMPORTANT! Export your branch for backup. Quick way: Make sure you can see your desktop, open a window that shows your root branched folder (in my case, "wwwroot"), right-drag it to your desktop, choose "Export here". Ignore this new export folder from here, unless you have problems.)
3. Right click on your branched folder ("wwwroot" again for me), choose "Merge" from the Tortoise submenu.
4. On the Merge screen that comes up, choose the first option: "Merge a range of revisions". Click "Next".
5. Change the "URL to merge from" to the trunk path. Leave the "Revision range to merge" field empty to bring the HEAD changes to you. (This example is assuming that the trunk has received commits after you branched and committed changes to your branch.) Click "Next" (or test merge to see what will happen).
6. Resolve any conflicts you might have, if this applies to your example.
7. You have now brought the latest trunk changes, and integrated them into your branch, bringing your branch up to date. Your branch now contains the most current commits to the trunk, as well as your branch's deviated changes.
8. Now, with the branch containing trunk changes, you need to re-commit your branch to SVN. Do this now.
9. Now, do an update on your branch, just to be sure. You should receive no updates, but this will ensure the metadata is up to date.
10. Next, do a "switch" on your folder, back to the trunk counterpart. This is in in the Tortoise submenu after right-clicking your branched folder. This allows you to merge the changes from your branch into your working copy of trunk, so that you can commit the branch-to-trunk merge back to SVN. (Earlier you brought the latest trunk changes to your branch, the opposite.)
11. After the switch is complete, go ahead and do an update.
12. Right click on your [trunk] folder, choose Merge from the submenu.
13. Choose "Reintegrate a branch" then click "Next".
14. Change, if needed, the "From URL:" dropdown to the branch SVN location.



No comments: