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 is 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 is stabilized and finished, the branch is then merged back into the trunk.
Creating a branch is simple. Simply make a copy of your project using svn copy
. This command requires 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 is almost always inside of your /branches directory. 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, right-click, and then select the command TortoiseSVN > Branch/Tag.
The default destination URL for the new branch is the source URL on which your working copy is based. Edit that URL to the new path for your branch/tag. For example, instead of:
https://subversion.assembla.com/svn/path/to/trunk
use something like:
https://subversion.assembla.com/svn/path/to/branch_name
Tagging revisions
You can tag certain revisions and recreate that build at a later date. Tags are typically 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 is already 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 is 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