Home About Subversion Key concepts About “trunk”, “tags” & “branches”

About “trunk”, “tags” & “branches”

Using the trunk and branches

Subversion is a very general purpose tool, and unlike some other version control systems, any specific structure you define in your repository is completely optional.

The most common structure people use to configure their Subversion repositories is to have three folders defined at the repository's top level, trunk, tags and branches.

In smaller software projects, the trunk folder usually contains the most current version of the project's files. Most people in the team will just have a working copy of the trunk stored on their own computers and do all of their work in there. In bigger projects, developers will often make a copy of the trunk in the branches folder, and do their work in a working copy of the branch they created.

Some teams let every developer work in their own development branch, periodically merging everyone's individual changes to the trunk. Another common approach is to create a seperate branch for major new versions of the project, or other large endeavors that will carry some dramatic changes to the entire project with them.

Tagging releases

The tags folder is used to create snapshots of the trunk at a specific revision. Most software teams use this method to tag individual releases of their software. Using tags in this way makes it easier for developers to get a copy of their application's source code for a specific given release.

It's just copying, mostly

To create a branch or tag, all you need to do is copy the entire trunk folder over to a new subfolder in the branches or tags folder. The easiest way to do this is to browse the repository (not the working copy) and make such a copy there. That way, Subversion can take care of the actual copying, instead of having to transfer the entire contents of the trunk to your local working copy and sending it back to the server again.

There is no need to be concerned about disk space, Subversion is quite smart about making copies. If two folders are nearly identical, Subversion will only store just enough information to be able to reliably reconstruct the files when you do a checkout or export.

Real world examples

To learn more about how to use the branches and tags folders effectively, take a look at any large open-source project's Subversion repository, like for instance WebKit. You’ll see that new development usually takes place in a branch and you’ll find tags for just about any release that ever went out the door.

Even if you do not see a direct need for the trunk, tags and branches folders in your project right now, if you use Subversion for something that will be released to people outside your team, it is still recommended to set up this default structure. If you ever do need to tag or branch, it's a lot easier to already have those folders around than to re-organize your repository later on.