svn: replace trunk with branch

Use svn move to move the contents of the old trunk somewhere else and rename the branch to trunk afterward.

Note that copy and move in svn work like file operations. You can use them to move/copy stuff around in your repository and these changes are versioned as well. Think of "move" as "copy+delete".

[EDIT] Nilbus just notified me that you will get merge conflicts when you use svn move.

I still think that this is the correct approach. It will cause conflicts but if you merge carefully, chances are that you won't lose any data. If that bothers you, use a better VCS like Mercurial or Git.


I was just looking at this problem recently, and the solution that I was very happy with was performing

svn merge --ignore-ancestry trunk-url branch-url

on the working copy of my trunk.

This does not try to apply changes in a historical manner (maintaining changes in the trunk). It simply "applies the diff" between the trunk and the branch. This will not create any conflicts for your users in the files that were not modified. You will however lose your Historical information from the branch, but that happens when you peform a merge anyway.


I agree with using the svn move command to accomplish this goal.

I know others here think its unusual, but I like to do it this way. When I have a feature branch and am ready to merge it with a trunk that has also be significantly modified, I will merge it to a new branch, usually named <FeatureBranchName>-Merged. Then I resolve conflicts and test the merged code. Once that's complete I move the trunk to the tags folder so I don't lose anything. Lastly I move my <FeatureBranchName>-Merged to the trunk.

In addition I prefer to avoid the working copy when doing the moves, here are samples of the commands:

svn move https://SVNUrl/svn/Repo/trunk https://SVNUrl/svn/Repo/tags/AnyName

svn move https://SVNUrl/svn/Repo/branches/BranchName-Merged https://SVNUrl/svn/Repo/trunk

Note: I use 1.5