Help Topic: The SVN Checkout Command


Maintained by: mikerb@mit.edu         Get PDF


Checking out a Repository with the checkout Command


The svn checkout command is likely the first comannd you'll need to know since this is how you get a local copy of an svn repository from a server to your machine. The basic command is simple, but there are a few other useful ways of using it that we discuss here. More info can always be found by Googling "Subversion book" and reading the full PDF online free, or just typing svn help checkout anytime on the command line.

Basic use of the svn checkout command    [top]


The basic syntax for the checkout command is:

  $ svn co <url>

For example the course software is checked out with:

  $ svn co https://oceanai.mit.edu/svn/moos-ivp-aro/trunk moos-ivp

Note that you can provide a name for the locally checked out directory that may be different than the repository name. In the example above, if you ommitted the "moos-ivp" as the last command-line argument, the checkout would have produced a file named "trunk" on your local machine.

Check out an older revision with the checkout command    [top]


One of the core strengths of a version control system is the ability to undo changes, or at least go back to an older version if need be. This can be done with the svn checkout command by providing information on the command line about the version you want to go back to. If I'm doing this, typically I make a copy of the newer/broken checkout, and then make a newer checkout with the revision I'm looking for. For example, you can check out a copy of the course software as it looked on February 17th, 2011, in the following way.

  $ ls 
  moos-ivp/
  $ mv moos-ivp moos-ivp-today
  $ ls
  moos-ivp-today/
  $ svn co -r "{2011-02-17}" https://oceanai.mit.edu/svn/moos-ivp-aro/trunk moos-ivp
  $ ls
  moos-ivp/   moos-ivp-today/

Sometimes specifying the desired revision ty the date is not sufficient. There may be multiple revisions checked in on that date. You may be working on a project where you and your partners checked in 50 changes yesterday alone. And you may need to go back to a particular revision. In this case you can get the revision number by using the svn log command. This is described in a separate topic. Also, the log may only help you if you add comments on each check-in. That's also a separate topic. But for the purposes here, if you know the revision number, say revision 523, you can checkout a copy of the tree using this instead of the date:

  $ svn co -r 523 https://oceanai.mit.edu/svn/moos-ivp-aro/trunk moos-ivp

Checking out just a subset of a repository    [top]


A nice feature of SVN is that is allows you to checkout just a subset of a repository. If for example the repository tree structure is:

  food/
    fruit/
      apples/
      grapes/
    vegetables/
      peppers/
      sprouts/

You can check out the entire tree with:

  $ svn co http://acme-software.org/svn/food

Or you can check out just a portion of the tree with:

  $ svn co https://acme-software.org/svn/fruit/grapes

Finally, in case you're curious, you may have noticed in the command we prescribe for checking out the moos-ivp tree:

  $ svn co https://oceanai.mit.edu/svn/moos-ivp-aro/trunk moos-ivp

This checkout requests only a portion (the trunk) of the full moos-ivp tree, which has a high-level structure that looks something like this:

  moos-ivp/
    trunk/
    releases/
      moos-ivp-12.2/
      moos-ivp-13.2/
      moos-ivp-13.5/
    branches/
      branch-beta/
      branch-kilroy/

Page built from LaTeX source using texwiki, developed at MIT. Errata to issues@moos-ivp.org. Get PDF