SVN creating trunk directory on existing repository

I am working a project that does not have a trunk / branches / tags directory structure - ie. everything is in the root of the svn repo.

I would like to create a trunk directory and in the root directory, and move everything in the root directory into the new trunk directory.

What is the best way to do this?

The first thing I considered was

svn mkdir trunk
(for each file or directory that is not called trunk: )
svn mv FILEorDIR trunk/

But this effectively deletes every file and then adds it again. Is there a better way?

Thanks.


I had exactly the same problem and solved it after looking through several different pages (this one included). Here's my solution:

Note: Before you begin, if you plan to use svn switch to keep your working copy and avoid checking out the repo again, it's best to make sure your working copy is up to date and has no uncommitted changes.

On with the solution...

//REPO_URL = The URL for the repo on the SVN server.
//In my case it was https://IP_ADDRESS:PORT/svn/my_repo

//Make the trunk dir in the root of your SVN repo
svn mkdir REPO_URL/trunk -m "making trunk dir"

//Move everything from your root dir to your new trunk dir
svn move REPO_URL/A_FOLDER REPO_URL/trunk/A_FOLDER -m "moving folders to trunk"
svn move REPO_URL/ANOTHER_FOLDER REPO_URL/trunk/ANOTHER_FOLDER -m "blah"
svn move REPO_URL/A_FILE.TXT REPO_URL/trunk/A_FILE.TXT -m "moving files to trunk"
//Keep going until you've moved everything from your root dir to the trunk dir...

So now, on your SVN server, everything is in the trunk folder. Sweet!

But my repo is 60GB and on a remote server. I'd rather not check that out again. svn switch will let you point your existing working copy to the new trunk dir so you can continue to work with the copy you have. Go into the root folder of your working copy and run svn switch REPO_URL/trunk --ignore-ancestry. It should say At revision X where X is the revision after you moved all of your files from the root directory into the trunk directory. That's it! Maybe do an SVN update for good measure :)


This is similar to the way I've done it in the past. Your solution actually copies each file, then deletes the original. Because of the way Subversion implements copies, the history for every file is preserved.

After doing this, you can point existing checkouts at the new location using svn switch.


If you are using eclipse IDE and Subclipse for SVN then you can go ahead and create folders in SVN and move all the files/dir from root to the trunk directory and then checkout the ProjectName/trunk to you eclipse workspace...


Old post but I too had the same issue with all my repos were in the root and not in trunks. This presented a problem when trying a simple git svn clone command. After hours of trial and error, it was a simple:

git svn clone --username byname http://www.MySVNserver.com:81/repos/project1 --no-metadata --trunk=.