Fixing Subversion branch and trunk directories

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

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • Technorati

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

About the Author

Dan Wilson is a self described computer geek with an opinion on too many things. Regardless of whether the topic is politics, computers, gadgets or social engineering, you can bet he's got an opinion and tends to share. He's currently employed as a software engineer and excels at web development using open-source technologies.