Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Svn switch from trunk to branch

Tags:

branch

svn

trunk

I am in the root folder of an SVN-hosted project's trunk and am exploring setting up two branches.

One branch will be a "snapshot" of the project at the current (stable) revision, and a second branch will be one I'll work on to apply some new code, test, and then upgrade the trunk to a new version.

My goal is to keep the snapshot as insurance and a quick way to get an older, stable version of our project. The second branch, once we apply fresh code and the tests pass, will be merged back into the trunk, which we offer to the public.

To set up the snapshot, I copied our trunk to a branch called v1p2p3:

$ svn cp https://www.example.com/svn/trunk \ 
         https://www.example.com/svn/branches/v1p2p3 \
         -m "Branching from root trunk to v1p2p3 at r1114"

So far, so good:

Committed revision 1115.

What I would like to do is switch my local repository copy to this branch, to make sure that things worked, but I get an error message:

$ svn switch --relocate https://www.example.com/svn/trunk \
                        https://www.example.com/svn/branches/v1p2p3

The error message is:

svn: E155024: Invalid relocation destination: 
              'https://www.example.com/svn/branches/v1p2p3' 
              (does not point to target)

What am I doing wrong?

(If this doesn't work, I suspect I can't get to starting on the more ambitious second branch. I'm looking for a way to do this that won't damage the existing project layout. Thanks for your advice, and apologies if this is a dumb question.)

like image 555
Alex Reynolds Avatar asked Feb 01 '13 23:02

Alex Reynolds


People also ask

How do I switch to a branch in svn?

When you svn switch your working copy to the branch, the local changes will remain. You can then test and commit them to the branch. You can , however, use svn switch with the --relocate switch if the URL of your server changes and you don't want to abandon an existing working copy.

How do I switch from svn to trunk branch?

To switch back, just provide the URL to the location in the repository from which you originally checked out your working copy: $ svn switch http://svn.red-bean.com/repos/trunk/vendors . U myproj/foo. txt U myproj/bar.

What is switch in Tortoise SVN?

Switch your current working copy to the newly created copy in the repository. Again select the top level folder of your project and use TortoiseSVN → Switch... from the context menu. In the next dialog enter the URL of the branch you just created. Select the Head Revision radio button and click on OK.


2 Answers

You don't need to --relocate since the branch is within the same repository URL. Just do:

svn switch https://www.example.com/svn/branches/v1p2p3
like image 54
tzaman Avatar answered Oct 20 '22 05:10

tzaman


  • Short version of (correct) tzaman answer will be (for fresh SVN)

    svn switch ^/branches/v1p2p3
    
  • --relocate switch is deprecated anyway, when it needed you'll have to use svn relocate command

  • Instead of creating snapshot-branch (ReadOnly) you can use tags (conventional RO labels for history)

On Windows, the caret character (^) must be escaped:

svn switch ^^/branches/v1p2p3
like image 41
Lazy Badger Avatar answered Oct 20 '22 04:10

Lazy Badger