Subversion in 5 minutes

June 27, 2009

I have recently installed a Subversion on my Ubuntu VM for my personal use:

  • Store little bit of source code , when I play with code
  • Store documents in order to keep a track of modifications

Subversion is a popular Software Configuration Management (SCM), the CVS successor.
Installing Subversion for a personal use is quite simple.
Distribution installation
Easy by using the Ubuntu package utility:

sudo apt-get install subversion

SNVServe
First we have to create a directory that will be the root to store all Subversion repositories.

mkdir /usr/local/repositories

Then, we will use a simple server in order give access to the repositories.
This server is called svnserve.

svnserve -d -r /usr/local/repositories

By using the command above, we tell the server to start from the created directory in daemon mode.
Once started the server will be accessible at the following URL: svn://localhost:3690/
Creating a repository
Now, we have to create a repository in order to store data.
Creating a repository (called test) can be done by using the following command:

svnadmin create /usr/local/repositories/test

This command will create the test folder containing the default Subversion repository structure.
Configuring access rights
Since, this repository is for a personal use, we will give write access to all users. To do that, it is necessary to modify the following file in the newly created repository test/conf/svn/svnserve.conf. Using these settings is certainly not advised in a production context.

# anon-access = read
anon-access=write

Creating repository structure
In Subversion, repositories have, usually the following structure:

  • trunk: Main development
  • tags: Space to store tags (label)
  • branches: Space to store branches

This is not mandatory but it is a convention, widely used.
So, we will initialize this structure by creating corresponding folders in a temporary directory called import-svn for e.g. and then import this structure in the repository.

mkdir -p /tmp/import-svn/trunk /tmp/import-svn/tags /tmp/import-svn/branches
svn import /tmp/import-svn/ svn://localhost:3690/test

You will have to cancel the edition of a comment text and to continue in order to commit the import.

If you want to use your repositories from outside the VM, you can forward the TCP port 3690 to 3699 for e.g. see this post for more details on port forwarding.