I started working on what I thought would be a small change to trunk, walked away for a month and now I realize this is really a whole side-project (full of bugs) that really needs its own branch. Furthermore, once I've branched these changes off, I want to reset my working copy back to what's currently in trunk so I can help out the main development effort and high-priority items before coming back to this side project when there's time.
So:
I would like to make a new branch, based on my working copy, without having to check in my working copy (it IS up to date with the latest HEAD revision though)
Once I have forked my working copy, I would like to basically remove all changes that are in the branch, and just set it to match the current HEAD revision in trunk.
What's the procedure? I'm using TortoiseSVN, but even command line instructions would be helpful.
A SVN branch copies the trunk and allows you to make changes. When the new feature is stable, the branch is merged back. Here's a basic step-by-step overview of SVN branching and merging. Create a branch using the svn copy command.
svn Getting started with svn Checking out a working copy Your local copy of the project is called a working copy in Subversion and you get it by issuing the command svn checkout <URL> where <URL> is a repository URL. e.g. Alternatively, you can use svn co <URL> as a shorthand in order to checkout a local copy.
If you want to create a snapshot of /calc/trunk exactly as it looks in the HEAD revision, make a copy of it: $ svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/tags/release-1.0 \ -m "Tagging the 1.0 release of the 'calc' project." Committed revision 902.
So I've tried two methods to branching my working copy without checking it in, not sure which one is going to end up being the best method:
Method 1: Copy entire directory to new branch
Method 2: use Branch/tag
It looks like Method 2 is definitely preferable.
Then, to clean up, it was a matter of Tortoise SVN > Revert... and "Delete all unversioned"
In command-line you can create a patch with the subversion "diff" command, and then apply it to your new branch with the subversion "patch" command. (You can read about these commands by executing 'svn help diff' and 'svn help patch'). Let's say you have the trunk and a branch called new_branch in the same parent directory.
cd trunk
svn diff > ..\my_stuff.diff
Now you have the patch, then apply it to your newly created branch.
cd new_branch
svn patch ..\my_stuff.diff
You can dry run the patch first by adding the --dry-run flag to the patch command, to see if anything strange happens before actually applying it.
svn patch ..\my_stuff.diff --dry-run
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With