Creating Your First Apache Subversion Branch
The concept of branching can strike fear into the hearts of Apache Subversion users, but when used correctly Subversion’s branching functionality is a powerful tool. In this week’s tip, we provide an intro to branching, by showing you how to create your first branch.
There are several ways to create a branch, but the ‘svn copy’ command is useful as it retains the folder’s history prior to the branch being created.
Tip. While it is possible to manually create a new file, copy your files over by hand and then commit this to the repository, this new branch will have no history prior to its creation.
To create your first branch in Subversion, use the ‘svn copy’ command followed by the file(s) you want to copy to the branch, and the location and filename of the branch you wish to create:
svn copy (working-copy-path/trunk) (working-copy-path/branches/name-of-branch)
In this example, we are copying all the contents of the trunk into a branch called ‘bugfix branch 1’
Now when you explore your working copy, you will notice a new file has been created – this is your new branch!
Tip. In Subversion branches and tags are effectively the same thing – a copy of an existing folder and its contents, in a new location within the same repository. The difference is all in the way you handle branches and tags, so it’s important to work out a sane project structure before you start branching.