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

57,927

Solution 1

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

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

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

Share:
57,927
Paul Alexander
Author by

Paul Alexander

I've been writing software since my Dad brought home an Apple II in '86 - can't really picture doing anything else. Most recently Senior Engineering Manager and Technical Lead at Twitter.

Updated on July 17, 2020

Comments

  • Paul Alexander
    Paul Alexander almost 4 years

    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?

  • thekozak
    thekozak about 9 years
    What do you mean by "It must not be the root of the repository, less to duplicate in that way"?
  • J Pollack
    J Pollack about 9 years
    I recommend not to choose the root folder with all the irrelevant sub-folders which are not subject to be modified in the branch. Later it will be easier to merge the (smaller) branch back to trunk.
  • ikku100
    ikku100 over 8 years
    In my case committing only that folder caused issues because the software depends on superfolders too. I think that's most often the case. I think for most use cases it's better to just commit the whole thing, so committing from the root I say is recommended.
  • simpleuser
    simpleuser about 8 years
    @ikku100 if there are no changes in those superfolders, how would it matter?
  • ikku100
    ikku100 about 8 years
    It could because people later on might commit changes there, but I guess you can check out the correct revision of the superfolder and then checkout the branch for the subfolder. Which is more work than just committing from the superdir, I think.
  • Frostrar
    Frostrar about 6 years
    Note that this approach will create the folder structure. No need to create the branch folder before performing the action