Fixing Subversion branch and trunk directories

subversionThe other day, at work, we came across a bad situation with Subversion (a version control system).  We had created a secondary repository for a common library (YUI) of code that we want to use in multiple other repositories.  YUI doesn’t provide a subversion repository, so we had to create one “in-house.”

I’m sure nobody else has done this (wink, wink), but we spaced off creating the typical trunk, branches and tags directories.  I think we assumed that we would never really need them.  But of course, there’s always a reason for following best practices.  We got to a point where one of our branches needed the old version of YUI (2.6.0) and the new branch needed the current YUI branch (2.7.0).  This didn’t work because of our lack of trunk/branches directory.  Here’s the steps I took to rectify the situation:

Check the trunk of your repo:

$ svn co $REPO_URL $REPO

Change directory into the checkout:

$ cd $REPO

Create the trunk directory, add it to the repo and commit:

$ mkdir trunk && svn add trunk && svn ci trunk -m “add new trunk directory”

Move all the files to trunk (has to be done with find because we can’t try to move trunk into itself):

$ find . -not -name trunk -maxdepth 1 -exec svn mv ‘{}’ trunk \;

Change directory to trunk:

$ cd trunk

Commit the moved files:

$ svn ci -m “move file into trunk”

Create the branches and tags directories:

$ cd ../ && mkdir branches && mkdir tags && svn ci -m “add new branches and tags directories”

Now you have a nice “best practices” setup with trunk, branches and tags directories.  You can now go about your normal branching.

NOTE: Apologies  to my non-techie readers

You may also like...

1 Response

  1. Mike W. says:

    Thanks for the apology.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.