How to Create a Branch in Subversion
December 08, 10 by adminI 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-branchCommitted 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:
- Right click on the main repository folder, under “TortoiseSVN” select the menu item: “Branch/tag…”
- Under “create copy in the repository from:”, select “HEAD revision in the repository”.
- Enter the new URL for the branch folder like “http://svn.servername.com/repos/reponame/branches/my-development-branch”
- 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