Branching

One of the most useful features of SVN is the ability to create branches to protect the source code from potentially destabilizing changes. Typically, branching can be used to try out and develop new features without disturbing the trunk (the main line of development) with errors and bugs. Then, once the new feature has been stabilized and finished, the branch can then be merged back into the trunk.

Creating a branch is simple. All you need to do is make a copy of your project using "svn copy". This command will require the URL of your project's /trunk directory as well as the URL of the directory where you want to create your branch. This location will virtually always be inside of your /branches directory. You'll need to name your branch to distinguish it from the other branches in the repository. 

svn copy <https://subversion.assembla.com/svn/path/to/trunk> \
         <https://subversion.assembla.com/svn/path/to/branch_name> \
         -m "commit message"

Creating Branches in TortoiseSVN

To create a branch with TortoiseSVN, select the folder in your working copy which you want to copy to a branch or tag, then right-click and select the command TortoiseSVNBranch/Tag....

The default destination URL for the new branch will be the source URL on which your working copy is based. You will need to edit that URL to the new path for your branch/tag. So instead of

https://subversion.assembla.com/svn/path/to/trunk

you might now use something like

https://subversion.assembla.com/svn/path/to/branch_name

Tagging

Also, you can tag certain revisions and recreate that build at a later date.

Typically, tags are used to create a snapshot of your project at a certain stage. They are not used for development and working on a tag revision is not a good idea.

If you need to make changes to a release which has already been tagged, create a new branch from the tag and then commit the branch. Do all of your work on the branch, and then create a new tag from that branch.

Creating a tag is exactly the same as creating a branch. The only difference is that the tag will be located inside of the tags directory instead of the previous branches directory.

There is no difference between branches and tags in Subversion. The only difference is in what the user then does with the directory. Branches are typically created, edited, and then merged back into the trunk. Alternatively, tags are created as a snapshot of the project at a point in time and then never changed.

Have questions? Email us support@assembla.com

Did this answer your question?