How should I structure my Subversion repository?

The traditional format for most SVN repositories is to create three top-level directories as follows (although it is entirely up to you whether you adopt this approach):

The main copy of all your project files would normally be located here. For most day-to-day work you would normally check-out and commit to your repository using this URL (rather than checking out the entire repository from the root).
New development (e.g. for a new feature) sometimes takes place on a branch here. This is so changes being made in the branch do not break the main trunk code base until the new feature is complete, at which point the final changes are “merged” back on to trunk. Old branches are usually deleted once they have been merged.
For each released software version you “tag” it by taking a complete copy of trunk/ and placing it here with a name to identify it (e.g. version-1.0/).

Note: Unlike other revision control systems such as CVS, there technically no difference between a branch and a tag in Subversion (they are both just copies of trunk). Because of this, it is usually important to ensure once a tag has been created that its contents are never modified. Doing so ensures that you can always checkout an exact snapshot of your files taken at the time the tag was created.

Tip: You can also setup subversion access permissions to enforce this, by only allowing an authorised user write access to the tags directory.


Leave a Reply