views:

18561

answers:

6

How do I create a branch in SVN?

+10  A: 

Subversion makes it easy (some think too easy) to create a new branch using the svn copy command.

$ svn copy svn+ssh://host.example.com/repos/project/trunk \
svn+ssh://host.example.com/repos/project/branch \
-m "Creating a branch of project"
sparkes
+4  A: 

Normally you'd copy it to svn+ssh://host.example.com/repos/project/branches/mybranch so that you can keep several branches in the repository, but your syntax is valid.

Here's some advice on how to set up your repository layout.

pix0r
A: 

If you even plan on merging your branch, I highly suggest you look at this:

http://www.orcaware.com/svn/wiki/Svnmerge.py

I hear Subversion 1.5 builds more of the merge tracking in, I have no experience with that. My project is on 1.4.x and svnmerge.py is a life saver!

basszero
+18  A: 

Subversion doesn't really support branches or tags. What it allows instead is a very very light and efficient copying facility.

Branching and Tagging are, effectively the same. Just copy a whole folder in the repository to somewhere else in the repository.

Basically this means that it is by convention what copying a folder means - whether it be a backup, tag, branch or whater. Depending upon how you want to think about things (normally depending upon which SCM tool you have used in the past) you need to set up a folder structure within your repository to support your style.

Common styles are to have a bunch of folders at the top of your repository called 'tags', 'branches' and 'trunk' etc. - that allows you to copy your whole 'trunk' (or sub-sets) into the tags and/or branches folders. If you have more than one project you might want to replicate this kind of structure under each project:

It can take a while to get used to the concept - but it works - just make sure you (and your team) are clear on the conventions that you are going to use. It is also a good idea to have a good naming convention - something that tells you why the branch/tag was made and whether it is still apropriate - consider ways of archiving branches that are obsolete.

Ronnie
"svn copy" has the advantage that it will retain history previous to the branching. Manually copying to another directory won't.
Hugo
A: 

If you use a tool like TortoiseSVN, it gives you a simple, visual mechanism for doing branching/tagging.

bcwood
+2  A: 

SVN Branching Howto

Nadir SOUALEM