How do I create a branch in SVN?
This question is related to
svn
version-control
branch
branching-and-merging
Create a new branch using the svn copy
command as follows:
$ svn copy svn+ssh://host.example.com/repos/project/trunk \
svn+ssh://host.example.com/repos/project/branches/NAME_OF_BRANCH \
-m "Creating a branch of project"
Suppose you want to create a branch from a trunk name (as "TEST") then use:
svn cp -m "CREATE BRANCH TEST" $svn_url/trunk $svn_url/branches/TEST
If you even plan on merging your branch, I highly suggest you look at this:
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!
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.
Top tip for new SVN users; this may help a little with getting the correct URLs quickly.
Run svn info
to display useful information about the current checked-out branch.
The URL should (if you run svn in the root folder) give you the URL you need to copy from.
Also to switch to the newly created branch, use the svn switch
command:
svn switch http://my.repo.url/myrepo/branches/newBranchName
If you're repo is available via https, you can use this command to branch ...
svn copy https://host.example.com/repos/project/trunk \
https://host.example.com/repos/project/branches/branch-name \
-m "Creating a branch of project"
Below are the steps to create a branch from trunk using TortoiseSVN in windows machine. This obviously needs TortoiseSVN client to be installed.
svn cp /trunk/ /branch/NEW_Branch
If you have some local changes in trunk then use Rsync
to sync changes
rsync -r -v -p --exclude ".svn" /trunk/ /branch/NEW_Branch
Source: Stackoverflow.com