Faking Fantastic
Confessions of a Web Developing Phony

Turn Current Working Trunk Into a Branch in SVN

So you start working inside of a trunk checkout of a Subversion repo, thinking that you will just be making a quick update. Once you start working, you realize it might have been better to make a branch to work on the feature separately from the trunk? Fear not! As Floyd Price from CodeSpaces points out, the process is pretty simple when you think about what you want to get done.

Technically, if you have not committed the changes into the trunk yet, you are dealing with the most up to date version of the trunk. If you were create a new branch from the trunk, they’d both be on the same page, sans your new edits.

Your current trunk checkout: A + B
               A new branch: A

To make the new branch, run:

#svn cp trunk_repo_path branch_repo_path/new-name
  svn cp http://example.com/repo/trunk http://example.com/repo/branches/new-branch

Now, in your current trunk repo check out you’ve been working in, switch the URL to be the new branch

svn switch http://example.com/repo/branches/new-branch .

If you run `svn st`, you will see the same modified files, but if you run `svn info` you will see the checkout’s URL now points to the branch, and you are free to commint

svn commit -m "first of commit new feature"

Hope this helps.