This is the story of a guy, Subversion and a server. Said guy wants to teach people about how to set up a Subversion repository on their Media Temple Grid-Service. Said guy does the job.

Disclamer: I’m certainly not a Subversion buff/expert, so there could be much better ways of handling this beast than mine. Also, this will go into depth of how I set up Subversion to manage the upcoming versions of all my sites. So obviously, it’ll focus on setting up Subversion in for the new (gs) server series from Media Temple.

So you’ve read all the introductions. Why Subversion is good and why you should use it. You’ve probably read the manual from front to back as well. You can svn update like a fox. But you want to start your own and have an idea of where to start. Hopefully this quick guide will help you put an end to your worries.

From the Beginning

The first thing you have to ask yourself, is what your structure will be. Because you’re probably going to be using Subversion for your production sites and not necessarily for building programs, then you’re probably not going to want to go with the old branch/, trunk/, tags/ methodology of doing things. Instead, the (gs) actually gives you a great way to start out your repository. If you were to type pwd at the command line when you’re working on any of your domains, you’ll see something like the below:

/home/237/users/.home/domains/avalonstar.com/html

Step 1’s done. There’s your structure. What I did with my repository is have my domains directory at a top-level (not the root directory, because I also have a design directory for all of my PSDs.) and then followed the structure above, creating a directory for each domain and then an html directory below that.

Creating the Beast

Now it’s time to create your repository. I have my own theory on what it actually is, since it’s a misconception that all of your data is mirrored in the repository when you commit anything. That’s not true, I think. When you create your subversion repository using the svnadmin create command, you’re actually creating the database which will store the data about your code, while the .svn directories inside each of your working directories keeps track of all the changes you make.

Hopefully I didn’t lose you.

So for all of you (mt) people, log in via SSH and type the following (note that the :~$ is just there to signify the bash prompt):


avalonstar.com@c126:~$ cd data
avalonstar.com@c126:~$ svnadmin create --fs-type fsfs subversion

Creating the Repository (Bash)

So what we’re doing here is creating a flat file system to keep our repository in, since (mt) is in the process of supporting WebDAV. Don’t know if they’re related, so we can skip that. The subversion in the 2nd line can be changed to whatever strikes your fancy. So what does this do you ask? This creates a directory with the name subversionin your data folder (Semantic, eh?), placing in it a bunch of files that you should never touch (unless you’re some Subversion god, therefore not even needing this guide).

Now that we have our repository made, it’s time to get something into it. Create a directory anywhere, probably in data/ since you’re already there and name it tmp. Now all you’re doing in this step is creating your directory structure, you could go on and upload all your files in this first step, but let’s keep it simple.


avalonstar.com@c126:~$ mkdir tmp
avalonstar.com@c126:~$ cd tmp
avalonstar.com@c126:~$ mkdir tags
avalonstar.com@c126:~$ mkdir designs
avalonstar.com@c126:~$ mkdir domains
avalonstar.com@c126:~$ cd domains
avalonstar.com@c126:~$ mkdir avalonstar.com
avalonstar.com@c126:~$ mkdir avalonstar.com/html
avalonstar.com@c126:~$ mkdir nyxsis-ro.com
avalonstar.com@c126:~$ mkdir nyxsis-ro.com/html
avalonstar.com@c126:~$ mkdir livefromthe101.com
avalonstar.com@c126:~$ mkdir livefromthe101.com/html
avalonstar.com@c126:~$ mkdir bryanveloso.com
avalonstar.com@c126:~$ mkdir bryanveloso.com/html

Directory Structure (Bash)

Easy right? Now, I said that you shouldn’t have to use a tags/ directory, but for people like me that have trouble keeping old things, I’ll be tagging (or literally, making an exact copy) the repository each month. Sort of like what developers do when they tag their releases.

The directories are there, you’re happy with the structure, now it’s time to make it the first revision in your repository. To do this, we’ll use svn import. Make sure you’re back in your tmp/ directory and type the following. (Don’t mind the > either.


avalonstar.com@c126:~$ svn import . file:///home/237/data/subversion -m "Creating initial repository structure."

Importing Directory Structure (Bash)

All I’m doing is telling Subversion to import everything in the directory I’m in (hence the period) to the repository located at file:///home/237/data/subversion with the given message.

If everything went well and you didn’t break anything, you should get a message saying that you committed revision 1. So you can rest, drink some coffee and relax.

Never FTP Again…

So for you lovelies with the (gs), cd over to your home/ directory and delete domains/ (hopefully you either backed up or haven’t done any work on it yet. Now, we’re going to pull the structure from the repository and use that to manage our domains! So enter the following:


avalonstar.com@c126:~$ svn co svn+ssh://serveradmin@avalonstar.com@s237.gridserver.com /home/237/data/subversion/domains/

Checking It Out (Bash)

So we’re literally checking out a copy of your repository to a newly reincarnated domains/ directory. Why do it this way? You’ll see in a second. We’re going to do the same thing on your local machine (this next part is mostly for Mac and *nix users, Windows users can do the same thing using TortoiseSVN). Navigate to a folder on your machine where you’d like to keep a copy of your files, and do the same command above. You’ll probably be prompted for a password, but if you don’t want to in the future then follow this handy tutorial from the guys at Macromates.

Whenever you need to upload something to your server, you can put it in your local checkout and then do an svn add and then an svn ci. Then all you have to do is head over to your server and do an svn up in your domains/ directory. And if you mess up like me, you can always wipe everything and do a fresh checkout.

Some Final Notes

At the moment Media Temple is working on supporting WebDAV, which gives you the ability to view your repository online (ex, http://svn.avalonstar.com, etc.). Also, WebDAV gives you the ability to make your repository public. These’ll all take time, but hopefully they’ll all be implemented in the near future.

Also, as questions come up, I’ll be appending this post, since I’m sure I haven’t covered everything. Hopefully this gave you a little introduction into getting yourself into the world of Subversion.