Intro to Branching in Subversion
For developers who aren’t familiar with version control, getting to grips with Apache Subversion’s branching functionality can be daunting. But, when used correctly, branching can be one of Subversion’s most powerful and useful features.
What is a Branch?
Put simply, a branch is a line of development that exists independently of another line.
Every project is different, but there are some common reasons why developers might choose to create a branch:
- To isolate development – This is often called a ‘concurrent development branch,’ and is the most common reason to create a branch.
- To experiment with new technology – Branches can be used to test a new technology that might not necessarily become a part of the main branch. If the experiment works out, the new code can easily be merged into the trunk.
- To tag a project and keep track of released code – This is often called a ‘release branch.’ Upon completing a release, it is a good idea to create a branch and tag it with a name that is meaningful to that release (for example, “release-2.0.”) This serves as an easy-to-retrieve record of how your code looked, in a certain release.
- To fulfil a particular customer’s need – This is often called a ‘custom branch,’ and is useful when you need to modify your project for a particular customer’s requirements.
Creating Your First Branch
To create a new branch, use the ‘svn copy’ command followed by a log message (-m) and the URL of both the resource being branched, and the location where you want to create your new branch:
svn copy -m “Creating a new branch” folder-being-branched location-of-new-branch
In this example, we are creating a new branch called ‘bug fix branch’ inside the ‘branches’ folder, that will contain all the files in the trunk:
Looking for a cross-platform graphical client for Apache Subversion? Claim your free 30 day trial at www.smartsvn.com/download