If you have ever been working on code to realize that you cannot commit the changes that you have made to the original branch you were working in, it might get a bit annoying. Fortunaltely, there is an easy way to commit your code in a new branch (without you losing any data).

In order to do that, you only need to follow three steps:

  1. Create a new branch in which you will commit your changes
  2. Switch your current working copy to this new branch
  3. Commit your changes to the new branch

The SVN command line for this are as follow:

1
2
3
svn copy -m "Creating new branch" https://url/to/existing/repository/branches/current_branch https://url/to/existing/repository/branches/new_branch
svn switch https://url/to/existing/repository/branches/new_branch .
svn commit -m "Saving my changes in the new branch"

Note that the command above assume that you are working from your working copy folder. If not, a simple cd /path/to/working/copy/. should suffice or you can adapt the second line to svn switch https://url/to/existing/repository/branches/new_branch /path/to/working/copy/.