How to Create a Branch and Tag in Apache Subversion

In Apache 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 main difference is the way the user handles branches and tags:

  • Branches – these should be used to work on significant changes, variations of code, and bug fixes.
  • Tags – should be used as “code milestones” that provide a snapshot of your project at a specified point.

In this post, we’ll show you how to create a branch, before providing an example of creating a tag.

Creating a 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:

Creating a Tag

Creating a tag uses exactly the same command, although it is good practice to create a dedicated ‘tags’ folder, where you can store all your tags.

In this example, we are creating a new tag called ‘Release1,’ again by copying the files currently in the trunk.

Tip. Whether you are creating a branch or a tag, it’s worth putting some thought into your naming strategy. A coherent naming strategy allows other team members to get an insight into what development work is happening in which branch/tag, at a glance.

0 Responses to “How to Create a Branch and Tag in Apache Subversion”

  • No Comments

Leave a Reply