SVN (Apache Subversion) Revision Control

SVN Server

Subversion server is installed on top of a running Apache HTTPD web server.
Web server must be setup first as described here.

Server installation

To install Subversion and Apache HTTPD module:

# Install subversion and Apache httpd mod_dav_svn
sudo apt-get install subversion libapache2-mod-svn

Server configuration

First, we create the subversion repository:

sudo -u www-data mkdir -p /var/www/svn
sudo -u www-data svnadmin create /var/www/svn/project

# Create the SVN repository.
mkdir svn svn/trunk svn/tags svn/branches
sudo -u www-data svn import svn file:///var/www/svn/project -m "Created project"
# Alternative (once HTTPS access is enabled):
# svn --username user import svn -m "Created project"
rm -rf svn

Enable http access to the repository

Repository must be added to web server configuration.

Note: SVN can uses the authentication mechanism from Apache webserver. The user file can be the same as the website or a specific one.

sudo vi /etc/apache2/sites-available/default-ssl.conf
               <Location /svn>
                        DAV svn
                        SVNParentPath /var/www/svn
                        AuthType Basic
                        AuthName "Depot Subversion"
                        AuthUserFile /var/www/svn.passwd
                        Require valid-user
# Create the password file
sudo htpasswd -c /var/www/svn.passwd user

# Restart web server to refresh configuration.
sudo /etc/init.d/apache2 restart

SVN Client

Online browsing

Repository can be accessed via any web browser:

firefox https://server/svn/project

Add a tree to svn repository

To add (import) a directory and all its content to SVN server:

svn --username user import src_dir -m "Initial version"

Note: the imported source directory is not becoming a working copy. The user still need to checkout the repository before modifying further.

Create a working copy

To create a working copy of the repository in a local folder:

# Add current directory to svn repository
svn import --username user -m "Initial version" .

# Create local copy of the SVN repository
svn co --username user src


Here are the most useful command to work with SVN:

# Add a file/dir to SVN
svn add src
svn commit -m "Some comment" src

# Review modified files
svn status
svn diff aFile.txt

# Update local copy to latest.
svn update

# Create a tag.
svn copy -m "Version 1.0."

# Diff vs. a tag.
svn diff --old= --new= --diff-cmd meld