Commit changes to a different branch than the currently checked out branch with subversion

SvnVersion ControlBranch

Svn Problem Overview


I've been working on code checked out from the development line and discovered that the changes made might be breaking changes and need to be moved to an experimental branch before committing to the main dev tree. However, I don't have the experimental branch checked out and I don't want to lose the changes that have already been made.

Is there a way to commit the changes in the working folder to a different branch than originally checked out?

Svn Solutions


Solution 1 - Svn

You should create a branch from a known sourceURL (this would be your 'development line' you mentioned in the question) first:

svn copy sourceURL branchURL

Then, switch to that branch:

svn switch branchURL

And commit your changes:

svn commit

Solution 2 - Svn

You could do it in the TortoiseSVN like that:

  • Right click on the directory where are the changes you want to branch. It must not be the root of the repository, less to duplicate in that way;
  • Select TortoiseSVN -> "Branch/tag...";
  • Set To URL: "svn://host/repository/FooBar/branches/FooBarBranchName";
  • Make sure [*] Working copy is selected. This will ensure the changes are commited;
  • Log message: "Experimenting with flies :)";
  • Optional: Tick [*] Switch working copy to new branch/tag. This is useful if you are planning to keep working on the new branch. Although you can switch to it later too.
  • Try to find the OK button. Hint: it is in the lower part of the window centred.

Enjoy!

Solution 3 - Svn

You can create a new branch directly from your working directory and switch the working directory to that branch.

The commands are svn copy and svn switch

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPaul AlexanderView Question on Stackoverflow
Solution 1 - SvnryanprayogoView Answer on Stackoverflow
Solution 2 - SvnJ PollackView Answer on Stackoverflow
Solution 3 - SvnDimaView Answer on Stackoverflow