Skip to Content

Getting Started with Subversion

Creating a Repository

Create a directory somewhere you and anyone else who will be sharing your repository can access it. You may want to request a new group from the systems staff that contains the usernames of everyone working on your project.

For Clinic projects, the best location for a repository will be somewhere in your shared Clinic directory; generally something like /home/clinic/year-year + 1/team/svnroot.

Once you have your directory, create a repository in that directory with svnadmin. For example, if you wanted to have separate repositories for your writing work and your code, you might run

svnadmin create --fs-type fsfs /home/clinic/2006-2007/myteam/svnroot/writing
svnadmin create --fs-type fsfs /home/clinic/2006-2007/myteam/svnroot/code

(If you prefer to have the code and your writing in the same repository, you might just create a single repository, as

svnadmin create --fs-type fsfs /home/clinic/2006-2007/myteam/svnroot/teamrepo

then create separate projects inside that repository.)

Setting Up Projects

Once you have a working repository, you will need to set up one or more projects to organize your work.

Traditionally, each project has a set of subdirectories that are used to further organize development. These directories are called trunk, branches, and tags. Most development goes on in the trunk, with disruptive work or work after a release happening in branches. The tags directory is used to label particular sets of files (for release, review, or just for convenience).

To create these subdirectories, you use the svn mkdir command, as in

svn mkdir file:///home/clinic/2006-2007/myteam/svnroot/writing/{trunk,tags,branches}

If you had multiple projects inside a single repository, you might create a top-level project directory with a command like

svn mkdir file:///home/clinic/2006-2007/d4nets/svnroot/writing/sow

then create the subdirectories for that project; for example,

svn mkdir file:///home/clinic/2006-2007/d4nets/svnroot/writing/sow/{trunk,tags,branches}

There's lots of good advice about work practices and how to set up a repository available in the books and websites on our resources page.

Adding Files

Once your repository is set up, you can start adding files. If you've already been working, and have some existing material to add, the easiest way to do so is probably to

  • Check out a working copy of your project's trunk directory from the repository with, for example,
    svn co file:///...svnroot/writing/sow/trunk sow

    (Creating a new directory called sow in your current directory that contains the latest revision of the project from the repository.)

  • Copy your existing files into your working copy (with the Unix cp command)
  • cd into your working copy and add the files (and subdirectories, if you have them) to the repository:
    svn add *
    svn ci -m "Initial check in of sow files." *

Now your teammates can check out their own copies of the project, make changes as necessary, and check them in with meaningful messages.