logo

Personal tools
Vasudeva Development Subversion Access Quick SVN tutorial
Document Actions

Quick SVN tutorial

Quick Subversion tutorial

Original article: http://www.germane-software.com/~ser/Files/Software/svntutorial.html
Copyright © 2002 by Sean Russell

Abstract

This document provides a brief tutorial on using Subversion. I'm using this to document the SVN tools as I learn to use them, and tips for administering an SVN repository. This is not intended to be a replacement for the SVN documentation, but rather a quick howto on using SVN.


Overview

This document provides a brief tutorial on using Subversion. I'm using this to document the SVN tools as I learn to use them, and tips for administering an SVN repository. This is not intended to be a replacement for the SVN documentation, but rather a quick howto on using SVN.

Here are a couple of differences between svn and cvs, but the primary is how SVN does versions. A version in SVN applies to the entire repository not just the files within the project. If what is in there is version 4 and I commit something, everything will now be version 5. As the svn docs explain it, you shouldn't think about "revision 5 of file X", but as "file X from revision 5".

Installing SVN

Subversion, as of the pre-alpha, is a pain to install; this is to be expected, but I would have rather that the SVN developers rely less on bleeding edge version of build tools, such as autoconf, libtool, Berkeley DB, etc.. The versions that SVN uses don't seem to exist as RPMs for most systems, so you'll end up building a lot of support tools by hand.

Things to be aware of: if you're building Apache yourself, don't use the recommended no-shared-libraries flag when you build subversion, or else it won't work. Download the Subversion sources and read and follow the nodes/dav_setup.txt file. This will help you build Apache. Then read the subversion/INSTALL file; you'll need to download the Berkeley DB sources; don't forget to unpack it into the subversion directory, and rename it to db. Then configure, build, and install subversion -- making sure to not use the --disable-shared flag.

After you've gotten Subversion installed by following the instructions, don't forget to run svnadmin to initialize the repository. This confused me for about 10 minutes until I realized that the DAV notes give some instructions out of order: they give instructions on testing the DB before the instructions on initializing the DB, which means that if you follow the instructions in order, testing will always fail.

Security is handled by Apache, not subversion, so you'll have to set up Apache security accordingly.

Managing repositories

Subversion manages branches a bit differently than CVS; there's a good document (SVN for CVS users) at the Subversion site. You should read that. The long short of it is that you have to restructure your directories a little bit before using Subversion. Caveat: this restructuring isn't neccessary, and the following tree hierarchy isn't neccessarily the best. However, while the documentation isn't clear on this subject, it implies that if you don't do this (or something like this) you may encounter difficulties later when you try to do branches.

Say you have a project that is laid out:

myproject/
index.html
src/
docs/
images/

Before you import the project into Subversion, you should restructure the hierarchy so that it looks like this:

myproject/
tags/
branches/
trunk/
index.html
src/
docs/
images/

You do this because to create a branch "sometag", you'll copy trunk/ to branches/sometag.

Anyway, after you've moved things around, make sure you've deleted any extraneous files, such as *~ and .*.swp. Make sure to delete those CVS directories, or they'll end up in the repository. Then, in the parent directory of "myproject", run the command: svn import http://yourhost/svn/repos myproject myproject. Don't forget the last argument, or else all of the files in myproject will be dumped into the main SVN repository directory... at the top of the hierarchy. To check out the project, use: svn checkout http://yourhost/svn/repos/myproject/trunk -d myproject. This will check out only the "trunk" subdirectory into "myproject" on your machine. You can then work in this subdirectory.

Other commands

Here are common commands I've used so far; they operate, for the most part, just like their CVS counterparts, with a few differences (and the power of SVN is in those differences).

  • help -- use svn help <command> to get very terse help on any command.

  • commit -- just like CVS commit

  • checkout -- see the instructions above for an example. Does what CVS checkout does, but with different arguments.

  • update -- just like CVS update, although the results are different. See the subversion documentation on the website for more information.

  • delete -- deletes a file or directory. Unlike CVS, this really deletes directories. You won't see the changes in your working directory until you commit and update.

  • status -- a useful version of the CVS status command. Works offline and produces human-readable output.

page created by admin last modified 2004-07-30 11:47