Based on a short guide I wrote for a friend, here’s a quick and simple software configuration management (SCM) / revision control system for small- to medium-sized offices. This guide will use subversion as the SCM tool; arguments as to the relative merits of various SCM tools are left as a research exercise for the reader. Needless to say, this is what I’d recommend to most people in such offices.
This assumes you’re running a GNU/Linux server and a variety of machines for clients (Windows, Mac, Linux, etc.). I recommend Ubuntu Linux for most installations. The server software will run on Windows, but I’ve no experience with such installations, so I won’t address them here. If you’re going with Windows, I recommend the very dense official Installing Subversion document. Commands given here are for Debian-based Linux distributions, but are nearly the same for others. For example, in Fedora substitute “yum” each time you see “apt-get”. (As always, work carefully; consult your local official geek for safe help.)
Create an SCM User Group
If you don’t already have a user group for your developers, make one. Let’s call the group “coders”. Type
sudo groupadd coders
Create New User Accounts
If your users don’t already have accounts, type
sudo useradd -m --groups coders johndoe
for each user, replacing “johndoe” with their chosen user names. Each user will have to log in (with telnet, ssh, on the console, etc.) and set a password (type “passwd”) before they can use their account.
Add Any Old User Accounts to the Group
If you had any users before creating the “coders” group, you’ll need to add them the the group now. For each old username, type (substituting the user names in for <username>, of course)
sudo usermod -a -G coders <username>
Install SSH Server
While Subversion can run both as a native server (listening on a port) and as an Apache (HTTP) module, it is much simpler for most folks to use it over SSH. It’s very secure and requires almost zero configuration. Don’t worry: you can always switch later, or even mix and match. This will get you up and running quickly. Open up a console on your server. Type
sudo apt-get install openssh-server
To test, type
You should be prompted to verify a key fingerprint; this is for security, and you can safely type “yes”. You should then be prompted for your user’s login password. You should now see your normal shell prompt; nothing impressive, but now you know you can connect over ssh. Type “exit” to get out of the ssh connection and back to your local shell.
Install Subversion Server Software
sudo apt-get install subversion subversion-tools
(You can download the subversion binaries or sources from tigris.org if you want, but the above is simpler.)
Create a Repository
You can store your subversion data anywhere you want, but for clarity I’ll choose “/home/svn”. We’ll make a repository called “testproject”; you can make as many repositories as you want. Type
sudo mkdir /home/svn sudo chown coders:coders /home/svn cd /home/svn svnadmin create testproject
Test the Repository
svn info 'svn+ssh://localhost/home/svn/testproject/'
If you see a handful of lines starting with things like “Last Changed” and “Revision”, your repository is working.
Create a Sane Repository Layout
There are occasionally reasons to deviate from the default subversion root layout, but those reasons are few and far between. We’ll make the standard root layout; type
svn mkdir 'svn+ssh://localhost/home/svn/testproject/trunk' \ 'svn+ssh://localhost/home/svn/testproject/branches' \ 'svn+ssh://localhost/home/svn/testproject/tags'
It seems like a lot to cut and paste, but you won’t have to type this much when you’re using subversion (just when setting it up).
Install Client Software
Take your pick of command-line or graphical (GUI) clients, based on the operating system you use.
- command line: cygwin, choosing the package “subversion”
- GUI: Putty + RapidSVN – Putty will provide the SSH connection. Download the most recent nightly build of RapidSVN, as I had trouble with SSH and the 0.9.4 release (this may have been fixed). Make sure you can Putty to your server and log in that way before trying to layer RapidSVN on top of it.
- command line: apt-get install subversion subversion-tools
- GUI: rapidsvn or kdesvn
Check Out the Project and Use It
In the below commands, replace “servername” with the name or IP address of your server. Note that we’re only checking out the trunk directory; we could check out the whole project, but every time someone made a tag you’d get a whole new set of tagged files.
- command line:
cd ~ svn checkout 'svn+ssh://servername/home/svn/testproject/trunk' testproject cd testproject echo 'testing' > somefile.txt svn add somefile.txt svn commit -m 'adding a test file'
- GUI: follow the instructions included with your particular GUI client, using svn+ssh://servername/home/svn/testproject/trunk for your repository URL.
You should now have a fully-working subversion server, ready for projects and code. Repeat the “svnadmin create” step for any projects you have, and either add the files by hand or use “svn import” on a client to import your existing code with no fuss.