Using Subversion for your Source Version Control

Branches and Tags

You create a branch when you want to work on a copy of a project and make changes without affecting the main project files (the trunk). You can then work independently on this new line of development while the rest of the team works on the main project. The branch is, in fact, just a copy of the main files, so you create it by copying the files onto a new directory.
> svn copy trunk branches/myProjectX

> svn commit -m  "Creation of a new branch of ProjectX"
Suppose now that you have worked on your branch for a while. The team has also continued the work on the trunk and they made some improvements to the lib directory of ProjectX that you wish to use. However, you also made some changes to these files. The solution is to merge the two sets of files using the command svn merge. This command proceed by considering two directories (or files) of the repository and merge them together into the local working copy. Now, if you want to merge your branch with the trunk and have the merge result apply to your branch, you need to have a copy of your branch on your local machine and be located under this directory when you issue the command.
> svn merge svn://www.server.ca:5555/test/projectX/trunk \

        svn://www.server.ca:5555/test/projectX/branches/myProjectX .
You can then run svn status to see what changes have been made.

A tag is a snapshot of your project that should not be changed after. To create a tag, you just need to create a copy of your project. This is done the same way as you do for branches. Note that there is a shortcut command that directly copy a directory to another one in the repository without having to use a local copy.

> svn copy svn://www.server.ca:5555/test/projectX/trunk \

        svn://www.server.ca:5555/test/projectX/tags/release2.03

Top of the page

 

(c) Robert Laganiere 2011