Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN creating trunk directory on existing repository

Tags:

svn

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.

like image 369
Joel Avatar asked Dec 06 '08 01:12

Joel


2 Answers

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 :)

like image 96
jxmallett Avatar answered Oct 03 '22 05:10

jxmallett


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.

like image 42
Greg Hewgill Avatar answered Oct 03 '22 06:10

Greg Hewgill