Tag Archive for 'tag'

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.

Subversion Tip of the Week

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.

Subversion Tip of the Week

Tagging Your First Release in Subversion

Apache Subversion remembers every change made to its files and repositories, giving you the option of rolling back to previous revisions when disaster strikes. To make rolling back easier, it’s good practice to explicitly label your project at certain points in the development effort (for example “Release 1.0.”) This is where tags come in.

Tags allow you to create a snapshot of your project, with a human-friendly label. Creating a tag follows the same process as creating a branch, although to avoid confusion it is a good idea to create a dedicated ‘tags’ directory. To create a tag, use the ‘svn copy’ command:

svn copy (working-copy-path/trunk) (working-copy-path/tags/name-of-tag)

In this example, we are copying the entire contents of the trunk to a folder called ‘Release 1.0’ in the ‘tags’ directory.

Now when you explore your working copy, you will see a new folder in the ‘tags’ directory.

You have just created your first tag!

Tagging Tips

Every project will be different but there are some common scenarios where tags can come in handy:

    • At a stable point during development.
    • To mark a release, or a patch.
    • Just before a complicated merge.


Note, as tags are supposed to be a snapshot of your project at a certain point in time, it is important not to modify the tag.

What Do ‘Trunk,’ ‘Branch’ and ‘Tag’ Really Mean?

‘Trunk,’ ‘tags’ and ‘branches’ are common conventions in Subversion, and most Subversion projects employ them in some shape or form, but there’s often some confusion surrounding these concepts. Essentially, ‘trunk,’ ‘tags’ and ‘branch’ all refer to directories in Subversion, but they’re used to distinguish how users handle these directories. Subversion doesn’t force you to organize your project into trunk, tags and branches, but arranging your data in this conventional format allows you to access the wealth of Subversion tutorials and guidelines online – and, of course, it makes it easier to reach out to the community for help if you get stuck! In this post, we provide a quick introduction to the trunk, tags and branches conventions, alongside some practical advice for getting the most out of these conventions.


The trunk is the main line of development in a Subversion repository. It contains the main codebase and is always stable. In the early days of a project, there will be little need for branches and tags, as you will spend most of your time making changes and committing them back to the trunk of your repository.


The Subversion repository remembers every change written to it. This allows the client to read the latest version of the filesystem tree, but also to view the previous states of the filesystem. Users can tag certain revisions of the repository with more human-readable file names (e.g “release-2.0”) for easy reference. In this scenario, if you ever need to look at the source code for version 2.0 again, you can easily locate the tagged file and pull the code back out.


Branching is a line of development that exists independently of another line. Branches allow developers to work on code independently of the work going on in the trunk. Branches can be made either from:

The working copy:

  • right-click on your working project and select branch/tag.
  • specify where you want the information to go.
  • add a log message to explain why you’re creating this branch.

The repository:

  • from within the repository browser, select where you want to branch from and right-click
  • select the ‘copy-to’ command
  • specify the name of the new branch and the location where the branch should be created
  • add an optional log message to describe why you’re creating this branch

So, when should you branch? Every project is slightly different, but there are some common reasons to create a branch:

1) Concurrent development branch: When performing concurrent development, to isolate development. This is the most common reason to create a branch.
2) Release branch: To tag a project and keep track of released code. Upon completing a release, the development team create a branch and tag it with a name that is meaningful to that release (e.g “release-2.0”) This provides an identifiable record of how the released code looks.
3) Experimental branch: To test a new technology that may not necessarily become a part of the main branch. If the experiment works out, the new code can always be merged into the trunk.
4) Custom branch: When modifying the code for a customer’s particular need.

You would not normally create a branch for small changes, and do not normally branch from the tags folder, as the tag folder specifies what a release looks like at a certain point in time, and branching from that folder can lead to confusion.

Ready to get started with Subversion? Binaries of the latest Apache Subversion releases can be downloaded from the WANdisco website now.