Is there any way to commit changes that I've made to my SVN checkout of trunk to a branch instead?
Asked Answered
C

3

7

I just started working on some changes against trunk on an SVN repo, thinking they would be somewhat small. Now, I actually am beginning to realize that I probably should have just started a new branch instead. Rather than making a branch, and then moving each individual piece into it, is there any way to make a new branch and then commit the changes in my working copy to it?

Cortisone answered 3/10, 2009 at 18:36 Comment(0)
W
13
  1. make a new branch from the place where you started developing
  2. switch to the newly created branch
  3. commit the local changes (will commit to the new branch)

DO NOT MAKE ANY CHECKOUT

I do it with svn 1.6.5, it works without trouble but if you are really paranoid you could do following:

  1. create a patch from current working copy
  2. create a branch
  3. switch to it
  4. apply the patch
  5. commit
Wrongful answered 3/10, 2009 at 18:41 Comment(5)
The only problem is that branching from my working copy never seems to work well for me. I suppose I should try the second set of steps.Cortisone
Actually branching can be done without working copy. If you use TortoiseSvn for example with the repository browser or from command line.Wrongful
I wanted to post a reference but svnbook.red-bean.com seems to be unreachable at the moment at least from europe...Wrongful
This worked perfectly for me (along with wcoenen's advice to svn up).Cortisone
This would benefit from an example command that creates a branch off of a specific revision of the trunk.Kala
J
2

What about creating a patch from your current work with svn diff, then making a new branch, and applying the patch to the branch with patch -p0?

Jackfruit answered 3/10, 2009 at 18:42 Comment(0)
R
2

You can directly branch the state of your working copy to a URL with the svn copy command. The created branch will include the local modifications.

Some gotchas:

  • you may get errors stating something like "File already exists". This is caused by a mismatch of base revisions in your working copy, more specifically between a file and its parent folder. One possible solution is to do a svn update before attempting to branch in this way.
  • after the svn copy, the working copy will be unchanged. It will still point to the trunk. It will also still show the local modifications in its status. You should first revert these modifications, whether you continue using the working copy as is or switch it to the new branch.
Research answered 4/10, 2009 at 0:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.