[svn] Svn switch from trunk to branch

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.)

This question is related to svn branch trunk

The answer is


In my case, I wanted to check out a new branch that has cut recently but it's it big in size and I want to save time and internet bandwidth, as I'm in a slow metered network

so I copped the previous branch that I already checked in

I went to the working directory, and from svn info, I can see it's on the previous branch I did the following command (you can find this command from svn switch --help)

svn switch ^/branches/newBranchName

go check svn info again you can see it is becoming the newBranchName go ahead and svn up

and this how I got the new branch easily, quickly with minimum data transmitting over the internet

hope sharing my case helps and speeds up your work


  • 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

Examples related to svn

Error "can't use subversion command line client : svn" when opening android project checked out from svn How to view changes made to files on a certain revision in Subversion Intellij idea subversion checkout error: `Cannot run program "svn"` How change default SVN username and password to commit changes? How to rename a file using svn? Connect Android Studio with SVN svn: E155004: ..(path of resource).. is already locked SVN Commit failed, access forbidden How to add an existing folder with files to SVN? Update OpenSSL on OS X with Homebrew

Examples related to branch

Get git branch name in Jenkins Pipeline/Jenkinsfile Why do I have to "git push --set-upstream origin <branch>"? Your configuration specifies to merge with the <branch name> from the remote, but no such ref was fetched.? When does Git refresh the list of remote branches? Fix GitLab error: "you are not allowed to push code to protected branches on this project"? Git push: "fatal 'origin' does not appear to be a git repository - fatal Could not read from remote repository." Git: Merge a Remote branch locally git pull from master into the development branch Depend on a branch or tag using a git URL in a package.json? How can I copy the content of a branch to a new local branch?

Examples related to trunk

Svn switch from trunk to branch What is trunk, branch and tag in Subversion? What do "branch", "tag" and "trunk" mean in Subversion repositories?