Subversion is a
version control system similar to CVS, but different in a number of respects
that make it more robust and quite a bit better. Subversion is quickly becoming
an extremely popular replacement for CVS. (In a previous tip, I showed you how
to connect to a
subversion repository
using an Apache 2 Web Server.)

A lot of the commands are similar to what CVS provides, but
they can be different in a few ways. The svn
command is the equivalent to the cvs command;
and svnadmin is the equivalent to the
cvs admin command.

Tips in your inbox

Delivered each Tuesday, TechRepublic’s free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills.

Automatically sign up today!

To create a subversion repository, use:

$ svnadmin create ~/subversion/repos

This would create a repository in your home directory in
~/subversion/repos. To add a directory to the repository, use:

$ svn mkdir file:///home/user/subversion/repos/www

This would add the directory www to your repository. To add a newly created file to the
repository in the www directory, use:

$ cd ~/subversion/repos/www
$ svn add index.php
$ svn commit

Then, if you were to make changes to index.php after it was
committed, you could view a diff of
the changes you made and then commit those changes:

$ svn diff index.php
$ svn commit

Note that svn looks
for the EDITOR or SVN_EDITOR environment variables to set the name of the text
editor to use when writing commit messages, but you can also specify the commit
log message on the command line using:

$ svn commit --message "Changed the copyright"

To checkout a working copy of something in the repository, you
would use:

$ svn checkout http://yourserver/svn/www


$ svn checkout file:///home/user/subversion/repos/www

You would use the former snippet if you have subversion setup
through Apache to access your repositories, and the latter is if you’re just
using a local repository.

To view those commit (log) messages for a particular file,

$ svn log index.php

These are pretty much the basics to using subversion, from a
client perspective. In a number of ways, the svn client is very similar to the cvs client; this was done intentionally to make the migration from cvs to svn a lot less painful and make subversion feel a little more
familiar to new users.