I made the mistake of creating a Subversion repository without the usual trunk
, branches
, and tags
directories. That is, the root directory of the project maps to the root directory of the repository. Now I want to create a feature branch, but there's no good place to put it. What I'd like to do is move /
to /trunk
, preserving its properties and history. Am I out of luck?

- 1,986
- 5
- 22
- 26
9 Answers
The clean way to do this is using svnadmin
to dump out the whole repository using
svnadmin dump
Then create a new repository with the trunk directory at the root, and reload the dump with
svnadmin load --parent-dir trunk
If you do an svn move then that will mess things up if you ever update back to a revision before the move, since the files will move back to their previous location, which is probably not what you want.

- 81,358
- 34
- 189
- 227

- 53,924
- 26
- 111
- 144
-
2@sleske - I've handled exactly this problem before - see my note about the problems of doing an svn move. This is the correct way to do it. – John Carter May 02 '10 at 15:00
-
I've not had a chance to try this, but it sounds like exactly the solution I'm looking for. – Adam Siler May 02 '10 at 15:49
-
Another plus of the excellent advice @therfromhere gives is that future svndumpfilter runs are going to work out. If you move the tree svndumpfilter is going to have problems. – thekbb Jun 29 '11 at 15:32
-
But if I have repository with multiple modules `calc calendar ...` and I want to change it into `calc/trunk calendar/trunk ...` then it is almost impossible. I may hack the dumo file, but when it contains come directory creations it becomes a nighmare. – xmedeko Jul 27 '11 at 12:22
Used therefromhere's answer, which worked fine, but wanted to add the commands including the parameters, i.e. as executed on the svn server's command line:
Dump your existing repository into a file:
svnadmin dump /path/to/myrepo/ > /some/dir/myproject.svndump
Create a new repository:
svnadmin create /path/to/mynewrepo/
Add the
trunk/
folder and commit it, in the working copy directory:mkdir trunk; svn add trunk; svn commit trunk -m "Add: trunk folder"
Load the dumpfile into the new repository using
trunk
asparent-dir
:svnadmin load --parent-dir trunk /path/to/mynewrepo/ < /some/dir/myproject.svndump
-
3It is easy to miss in the instructions, but this should be run on the *server*, not the working copy. Otherwise you'll get "Can't open file '/path/to/myrepo/format': No such file or directory." – DavGarcia May 01 '13 at 19:35
The easiest way would be to create a 'trunk' directory, then move everything else into it. You'll have to copy any properties manually, but it shouldn't be a big deal. The history is per-file, so it should remain.
The other issue to consider is whether anybody else has the repository open. It'll be difficult to merge, so make sure everyone has their changes checked in before you do this.

- 155
- 3
-
1It is the easiest way, but you need to beware that if you ever update back to a revision before the move then unexpected things will happen (your working copy will delete itself ;) ) – John Carter May 02 '10 at 15:02
-
Agreed. It's a bit trickier to use `svnadmin` but the results are better, and the merge issues are no worse than in the naïve method. I voted your answer up. – Benjamin Geiger May 02 '10 at 15:06
-
Conceptually, what is now `/trunk` is what used to be `/`, however this solution does not maintain history in a way that represents this. Running `svn log` on trunk will not show the history that was previously available on the root folder, which I think is what the OP wants. – HappyDog Sep 16 '19 at 09:49
As the other answers point out, just doing a svn mv into the trunk directory will do this. To then update your working copy, check out the svn switch command.

- 26,430
- 45
- 154
- 229
-
This seems to make the most sense, I wish I could vote ^3+. I am uncertain what command line commands happened under the covers but with TortoiseSVN I used Repo-Browser to create a "trunk" directory and then dragged-and-dropped the versioned contents into the trunk directory with "Move to trunk" appearing as a tooltip. All logs were retained. I failed to use svn switch, I just deleted the .svn metadata directory and re-checked out, but I'm sure svn switch would have made more sense. – Jon Davis May 04 '12 at 23:31
No just create a trunk
folder and move all the contents of the root to it. You can do it from explorer or through the repo-browser, the history will persist.

- 80,725
- 18
- 167
- 237
You need to create /trunk
and do an svn move of all contents of root inside the trunk and then commit.
After that you'll switch
your working copy to /trunk
.

- 31,725
- 15
- 104
- 153
-
This will move the files alright, but if you do an `svn log` on the trunk folder then all you'll see is the initial commit that moved the files. You won't get the full history, which I think is what the OP wants. – HappyDog Sep 16 '19 at 09:47
There are some gotcha's or limitations with some of the discussed approaches. The post below discusses another approach, which involves dumping the repo and editing the file paths. This has the benefit that moved files will be properly modified too.
http://dotslashstar.blogspot.com/2011/06/svn-hack-insert-missing-trunk-root.html

- 11
- 1
Quick example of how I did it.
I wanted to move file:///svn/myRepo
to file:///svn/myRepo/trunk
cd /
svnadmin dump /svn/myRepo > my.dump
killall svnserve
sudo rm -r -f /svn/myRepo
svnadmin create /svn/myRepo
svnserve -d -r /svn
svn mkdir file:///svn/myRepo/trunk -m "Created trunk dir"
svnadmin load /svn/myRepo --parent-dir trunk < my.dump