Creation and management of Branches/Tags

One of the fundamental features of version control systems is the ability to create a new line of development from the main one. This new line of development will always share a common history with the main line if you look far enough back in time. This line is known as a branch. Branches are mostly used to try out features or fixes. When the feature or fix is finished, the branch can be merged back into the main branch (trunk).

Another feature of version control systems is the ability to take a snapshot of a particular revision, so you can at any time recreate a certain build or environment. This is known as tagging. Tagging is especially useful when making release versions.

In Subversion there is no difference between a tag and a branch. On the repository both are ordinary directories that are created by copying. The trick is that they are cheap copies instead of physical copies. Cheap copies are similar to hard links in Unix, which means that they merely link to a specific tree and revision without making a physical copy. As a result branches and tags occupy little space on the repository and are created very quickly.

As long as nobody ever commits to the directory in question, it remains a tag. If people start committing to it, it becomes a branch.

Create a Branch/Tag

In the Working Copy view or in the Repository view, select the resource which you want to copy to a branch or tag, then select the command Branch/Tag... from the Tools menu.

Figure 3.19. The Branch/Tag dialog

The Branch/Tag dialog

The default target URL for the new branch/tag will be the repository URL of the selected resource from your working copy, divided in two: the URL of the parent and the selected resource's name. You may specify other resource name if you want to make a branch/tag using a different name than the one of the selected resource, by modifying the field labeled "Under the name:". The new branch/tag will be created as child of the specified repository directory URL and having the new provided name. To change the parent directory URL to the new path for your branch/tag, click on the Browse button and choose a repository target directory for your resource.

You can also specify the source of the copy. There are three options:

  • HEAD revision in the repository - The new branch/tag will be copied in the repository from the HEAD revision. The branch will be created very quickly as the repository will make a cheap copy.

  • Specific revision in the repository - The new branch will be copied in the repository but you can specify exactly the desired revision. This is useful for example if you forgot to make a branch/tag when you released your application. If you click on the History button on the right you can select the revision number from the History dialog. This type of branch will also be created very quickly.

  • Working copy - The new branch will be a copy of your local working copy. If you have updated some files to an older revision in your working copy, or if you have made local changes, that is exactly what goes into the copy. This involves transferring some data from your working copy back to the repository, more exactly the locally modified files.

When you are ready to create the new branch/tag, write a commit comment in the corresponding field and press the OK button.