Creating Subversion Repositories

Subversion is a free/open-source version control system. That is, Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data, or examine the history of how your data changed. It is a general system that can be used to manage any collection of files.

Subversion is a great tool for colaborative work. Whenever there is need for me to work with other people sharing files (software development or text writing, mostly) I set up a Subversion repository and grant access to those who need it.

This page gives minimal instructions on how to create a Subversion repository like mine on a Debian-GNU/Linux system. The same recipe should "almost work" on any other Unix system.


You need

An account on a host accessible via ssh, with Subversion installed in it. You do not need to be root. All actions should be performed as an ordinary user.


In this example,

host.domain.org is a system accessible via ssh, with Subversion installed.

calvin is your "login name" at host.domain.org.

/home/calvin/svn is the absolute path to the directory where your repository will be created (it could be any other existing directory name to which you have permission to read, write and execute).

transmogrifier is the name of the repository to be created.

hobbes and susie are the names of the only people who are going to have access to the repository. Note that neither of them need to have an account at host.domain.org.

All of the following assumes that you (calvin) are logged at host.domain.org

To create the repository, run

svnadmin create /home/calvin/svn/transmogrifier

To disable anonymous access, edit /home/calvin/svn/transmogrifier/conf/svnserve.conf and add the line

anon-access = none

To enable access control, edit /home/calvin/svn/transmogrifier/conf/svnserve.conf and uncomment the line

# authz-db = authz

To grant access to the users, edit /home/calvin/svn/transmogrifier/conf/authz and add the lines

[/]
calvin = rw
hobbes = rw
susie = rw
* =

Then, edit /home/calvin/.ssh/authorized_keys and add the following lines

command="svnserve --root=/home/calvin/svn --tunnel --tunnel-user=hobbes",no-port-forwarding,no-X11-forwarding <hobbes' public key>

command="svnserve --root=/home/calvin/svn --tunnel --tunnel-user=susie",no-port-forwarding,no-X11-forwarding <susie's public key>

From this point on, hobbes and susie have access to the repository. They can can "checkout" transmogrifier by running

svn checkout svn+ssh://calvin@host.domain.org/transmogrifier

To have the system sending an e-mail automatically at each "commit"

cp /home/calvin/svn/transmogrifier/hooks/post-commit.tmpl path/transmogrifier/hooks/post-commit
chmod +x /home/calvin/svn/transmogrifier/hooks/post-commit
cp /usr/share/subversion/hook-scripts/mailer/mailer.conf.example /home/calvin/svn/transmogrifier/conf/mailer.conf

Edit /home/calvin/svn/transmogrifier/hooks/post-commit changing the line

/usr/share/subversion/hook-scripts/commit-email.pl "$REPOS" "$REV" ...

to

/usr/share/subversion/hook-scripts/mailer/mailer.py commit "$REPOS" "$REV"

Edit /home/calvin/svn/transmogrifier/conf/mailer.conf:

Uncomment the line

#mail_command = /usr/sbin/sendmail

and change the line

to_addr = invalid@example.com

to

to_addr = <your e-mail address> <hobbes' e-mail address> <susie's e-mail address>

Home