Table of contents
Sometimes you are forced to use Subversion… It happens specially when some repos on your company are tied to this old technology! After many attempts on trying to do branching in SVN, I finally came up with a workflow that seems to work. Here on this page I describe the branching workflow that works for me.
Create a branch
I will be using Tortoise SVN. Let us imagine that we have a src/ folder that all the changes on files we might do are within this folder. My trunk/ and src/ folders look like:
Now, let us create a branch (“cheap copy” really): With the src/ folder selected, right click > tortoiseSVN > Branch/Tag, as following:
Now, we select to which branch folder we want the src/ folder to be “copied”. I like to create a folder under /branch with a description of te feature to be developed:
Add a commit message and press “Ok”:
Now, we have a copy of the “HEAD revision” of the trunk/src folder under the branches/feature-xpto. One could go to the branches/ folder and start working in the feature branch, however we would have to TortoiseSVN > Switch… (to switch the working directory). I prefer not to, and believe I tried. The way I prefer to do it would be to create another folder /_branching on the root of the SVN repo, and create a folder with the name of the feature branch we just created “feature-xpto”.
On this dir, let’s do an SVN checkout of the create feature branch:
Press “ok” and our feature branch folder should now contain the following files:
Now, work on your feature and when you are ready, commit to /branches/feature-xpto:
Merge the branch into trunk
When the new feature is ready for production, it needs to be merged into the trunk. To do so, navigate to trunk and right click under src/ folder > TortoiseSVN > Merge. The following window pops up:
Here we select the branch to merge from and the specific revision to be merged:
Press “Next” and press “Merge”. Conflicts might appear if someone committed to the trunk while you were working on the feature branch. If all goes ok, you should see the following window:
Finally, commit the trunk by right clinking > TortoiseSVN > Commit and write your merge commit message.
Branching on SVN can be a pain. This setup is not ideal but it works for me. Hope it’s useful to someone out there. Happy coding! ah, use Git, Git is awesome!!!