SVN Copy – Creating a Branch or Tag

Tagging and branching with svn are as simple as using the copy command. For this tutorial, I will assume that your repository has the following structure:

/path/to/repository/branches

/path/to/repository/tags

/path/to/repository/trunk

To create a tag of the trunk, run the following command:

svn copy http://svn.example.com/path/to/repository/trunk http://svn.example.com/path/to/repository/tags/snapshot-of-trunk

To create a tag of your current working copy (assuming you are in that directory on your local machine):

svn copy . http://svn.example.com/path/to/repository/tags/working-copy-seth

To tag a branch, say before merging the branch back into the trunk, run the following command:

svn copy http://svn.example.com/path/to/repository/branches/branch-seth/ http://svn.example.com/path/to/repository/tags/snapshot-branch-seth

To create a branch of the trunk:

svn copy http://svn.example.com/path/to/repository/trunk http://svn.example.com/path/to/repository/branches/branch-seth

To create a branch of your current working copy:

svn copy . http://svn.example.com/path/to/repository/branches/branch-seth

Tags should only be used to create snapshots of the repository. No development should be done on a tag, meaning you should never commit code to a tag. Branches are used for development that you do not want to interfere with everyday activity. They can be used for experimental code, code that you may only want to have run on your local machine, but still would like to have the power of version control behind your code. There are many other situations in which you would want to use a tag or a branch. You can read more about subversion and tags and branches on Wikipedia.

1 comment

  1. Hi,

    in branches i copied a new branch folder. Its normally only in subversion, not a real folder on my server?! I tried to delete this new_folder with

    svn delete ^/branches/new_branch -m

    and i get: svn: >>.<< is no working copy

    Maybe you can say, how i can delete this new_branch folder in svn completely.

Comments are closed.