SVN creating trunk directory on existing repository

Viewed 66207

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.

7 Answers

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.

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=.

I did this myself serveral times and learned this: If you want to keep the history of the previous SVN root directory + keep all SVN properties (like ignore) you must do it the following way. Notice: I did it all with TortoiseSVN, because it is very easy this way. But you may have also success with the command line. Below you find a description to do it with CLI too.

Do not forget to add appropiate SVN messages to each action, so you know later nice and clean what have been done.

Example repo: /svn/my_project

Steps for TortoiseSVN:

  1. Rename current project directory /svn/my_project to trunk /svn/trunk
  2. Create a new directory /svn/my_project
  3. Move /svn/trunk to /svn/my_project
  4. Switch working copies to new path. Check the checkbox "Ingore ancestry".
  5. Relax

Steps for the CLI (untested!):

  1. Copy the directory to a new directory /svn/trunk/
  2. Delete the old directory /svn/my_project/
  3. Copy the /svn/trunk/ directory to a new directory /svn/my_project/trunk
  4. Delete the /svn/trunk/ directory
  5. Switch working copies to new directory
Related