How to Create a Branch in Subversion

December 08, 10 by admin
Tortoise SVN

Subversion Client for Windows

I recently came across the need to create a new branch for my Subversion repository.  Below are my notes on how to perform this task using the SVN command-line under Unix/Windows and also instructions for performing the same task using TortoiseSVN (a windows GUI interface and client for Subversion). I hope this information is helpful for others needing to branch their own source repository.

1)    Checkout at the top-most level (above the trunk) into a working folder

$ svn checkout http://svn.servername.com/repos/reponame mybranch

2)    Create a copy of the project in the repository using SVN COPY command

$ cd mybranch
$ svn copy trunk branches/my-development-branch

$ svn status

A  +   branches/my-development-branch

3)    Commit the newly added branch to the repository

$ svn commit -m “Adding a new branch of /reponame/trunk.”
Adding         branches/my-development-branch

Committed revision 255.

4)    An easier method combining all of the three steps above!

$ svn copy http://svn.servername.com/repos/reponame/trunk \
http://svn.servername.com/repos/reponame/branches/my-development-branch \
-m “Creating a private branch of /reponame/trunk.”

Committed revision 255.

Of course if you are using the TortoiseSVN for Windows, you can simply perform the following steps:

  1. Right click on the main repository folder, under “TortoiseSVN” select the menu item: “Branch/tag…”
  2. Under “create copy in the repository from:”, select “HEAD revision in the repository”.
  3. Enter the new URL for the branch folder like “http://svn.servername.com/repos/reponame/branches/my-development-branch”
  4. Enter a comment for your new branch like “Creating a new branch of the repository”

That’s it, your branch has been created and you can check out this new branch into a new working folder using the normal SVN checkout procedure.  Just make sure to specify the new branch URL that you entered in step #3 above.  Good

Add your comment

One response for this post

  1. chiropracticien Says:

    My partner and I absolutely love your blog and find many of
    your post’s to be just what I’m looking for. Do you offer guest writers
    to write content for yourself? I wouldn’t mind publishing a post or elaborating on some
    of the subjects you write in relation to here.
    Again, awesome site!

Leave a Reply

You must be logged in to post a comment.