SVN Commit Working Copy to New Branch

By Jimmy Bonney | October 10, 2011

New branch

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



For the time being, comments are managed by Disqus, a third-party library. I will eventually replace it with another solution, but the timeline is unclear. Considering the amount of data being loaded, if you would like to view comments or post a comment, click on the button below. For more information about why you see this button, take a look at the following article.