Shelving in Subversion

Ever since I first saw shelving in the new version of Visual Source Safe, I've been somewhat enthralled by it. The first thing I did was figure out how I could do that with. I started typing an email to the Svn mailing list and then I realized how simple it was to do already. All you need to do is use branches.

Here's how to do it with...

  1. Create a shelves directory in the root of your repository (alongside the branches, tags, and trunk directories)
  2. If desired, create a subdirectory for each developer on the team to allow shelves to be separated by developer (i.e. shelves/flanakin/)
  3. Update files as needed
  4. Select the directory that needs to be shelved
  5. Select TortoiseSVN > Branch/Tag...
  6. Specify the a new shelved directory for the developer (i.e. shelves/flanakin/req1234), use the working copy, choose whether or not to switch to that shelf (for further work), and click OK

You now have shelved code. Other developers can grab that in one of two ways: by switching or simply merging with their existing working copy. Switch if you don't plan on finishing the shelved code; merge if you plan on unshelving it and committing it into the trunk (or another branch).

Man, all these CM code words make it sound worse than it really is. It truly is a simple task, if you've ever branched or tagged with Svn. Same implementation, different concept. I'd love to see the shelving concept be integrated into the Svn docs. The term, "shelving," seems to be new, but the concept is old. Some are referring to it as private branches. Whatever it's called (I like shelving better, tho), it should be in the best practices. Best of luck to those who use it!

This article is part of the GWB Archives. Original Author: Michael Flanakin

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.