Subversion Demystified using WordPress
June 27th, 2008 under How-to
In this tutorial, I’m going to explain to you the basics of how to get started with Subversion (SVN) using WordPress as an example in order to speed up your work flow as a blogger. When you finish reading this how-to, you’ll be comfortable navigating the command line, successfully gain access to a svn repository, transfer files to your local machine and update your copy of the files when a newer version comes out.
What is Subversion?
First of all, what is subversion? In a nutshell:
“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. In this regard, many people think of a version control system as a sort of “time machine”.” - svnbook.red-bean.com
With that kind of abstraction, you can apply subversion to a lot of different scenarios. On the web it is most commonly used for (but not limited to) source code management in open source applications, like WordPress.
Why use Subversion?
You should consider trying out subversion if your in need to manage versions of your project, track changes, or collaborate with others. In other words, subversion can bring order and structure to your project. For example, using subversion you can practically automate the installation and upgrade process of your WordPress powered blogs by the enter of two commands! That’s right, no more long unsecured FTP uploading sessions that take forever! All it takes is a little D.I.Y. spirit and an awesome How-to explaining everything you need to know!
File structure of a recommended SVN repository
In order to get acquainted with subversion, you’ve got to understand how it works right? Well, in a typical repository (which is a set of organized files and sub folders inside one master directory) you’ll have three main folders:
Trunk
Files located in the trunk directory are the latest version publicly available for testing purposes. It is usually unstable and not recommended for production use since this directory is being actively developed on and your more likely to find things not working. Other terms such as nightly builds, or “the bleeding edge” are typically refer to as the trunk directory.
Branches
Branches are copies of the trunk directory whenever the project reaches a major release point (e.g. version 2.2, 2.3, 2.5). This is the directory you’d want to navigate to in order to get a stable copy of the project.
Tags
Tags are most commonly used as “snapshots” of the project which are then lefted untouched. They typically highlight minor releases of the project (e.g. version 2.3.2, 2.3.3, 2.5.1). Theme Authors and Plugin Developers generally pull from this directory in order to grab an older version for backwards compatibility testing.
Getting Started: Man your Terminal
Now that you know the basic file structure of a SVN repository, it’s time to learn how to interact with it. The most common interface for doing so is through the terminal (command line for windows). Mac users with leopard should already have subversion pre-installed. Windows users can download the installer here if you don’t already have it. Shouldn’t take long.
Once subversion is successfully installed, your ready to start typing in some commands! Note: You don’t need a local web server if you don’t have one. If you do, great but using it is outside this tutorial’s scope.
Right now we just need to get use to navigating through our files and folders and download/update our copy of WordPress using the terminal window before take this on to our remote server.
Essential Commands you’ll need:
Navigating around files and folders using the terminal is a bit different from your typical GUI. At first, it’s a little challenging figuring out what directory your currently located in. If you ever get lost, simply type:
ls(mac)dir(win)
This command list all files/folders in your current directory. Now, time to navigate in and out of folders. In order to do so, simply type:
cdfoldername
Where you replace foldername with the name of the folder you want to navigate into. To leave your current directory, simply type:
cd ..
And you’ll go back one directory. Easy huh? Keep playing around with these commands until you feel comfortable moving around directories and listing what’s in your current directory.
Tip: tired of typing those long folder names? Here’s a shortcut: Instead of typing out the full foldername, you can just type cd folder* to quickly navigate to foldername. No need to type the full name of the folder.
Done? Alright, awesome. Now let’s create a directory to install WordPress locally. To make a directory, simply type:
mkdirwordpress (mac)mdwordpress (win)
The folder name doesn’t matter, you can type whatever you want. Step 2, download a fresh copy of WordPress from their svn repository:
- svn co http://svn.automattic.com/wordpress/trunk wordpress
Notice that there’s a space after the URL following the directory to where I want all the files to go. Upon pressing Enter you’ll see tons of files flying into your computer. Should take about 10 seconds.

That’s it. If you had a local server, (and you were located inside your wwwroot) you’ll be able to proceed with the famous 5 minute install.
To confirm that everything’s in there, just cd wordpress then ls (dir win) and you should see the standard WordPress files and folders. Let’s finish this up and delete everything. To do so, simply cd .. out of the directory and type:
rm -rfwordpress (mac)rd /swordpress (win)
Part 2: SSH into your remote server
Now that we’ve learned how to get the latest copy of WordPress onto our computer, it’s time to put that practice into practical use. A few prerequisites before we start should be to check whether your hosting provided allows shell access (which it should). If so, we’ll need to enable it and create a username/password to gain access to it from the command line.
I’m using Dreamhost. *cough*sign up with dreamhost*cough*:

Enabling shell access should be somewhere around the ftp settings. Check out the FAQ section if you can’t find it.
Note: For windows users, SSH isn’t install by default so you’ll need to install a SSH client, like PuTTY in order to continue.
Gaining access to your remote server is pretty simple. Just type:
sshusername@yourdomain.com (mac - terminal)sshyourdomain.com (win - PuTTY)
Depending on the system, you should be asked for your username/password you just made. Once you put that in, your in:

Once you’ve successfully logged in, let’s find out where we are.
ls(mac)dir(win)
If your a domain shopper like me, you’ll see a collection of all your domain names labeled as folders. Find the domain you want to install WordPress in and navigate into it (cd yourdomain.com).
Note: Windows users will now use the same commands as mac users (e.g. no more dir—use ls).
Warning: Your running these commands on your remote server, make sure you’ve got everything backed up before you continue. Although you can continue without backing up, please still do so. You’ll make me feel better.
Alright, with that said, navigate to your domain’s folder where you want to install WordPress and type:
svn cohttp://svn.automattic.com/wordpress/branches/2.5 .
Noticed the space then a dot after the URL, which is intentional. It means put these files in the directory that I’m currently in (or, working directory for short). If you rather install WordPress in a sub-folder then remove the dot and replace it with the name of the folder you want.
Pressing Enter will override any previous installation if you have one.
Once all the files transfer over, your done! You’ve successfully installed WordPress Subversion style.
To update your copy of WordPress if a newer version comes out, simply type:
- svn up
However, when a new major release (e.g. 2.6) comes out, that method won’t work. Type this instead:
svn cohttp://svn.automattic.com/wordpress/branches/x.x .
Where x.x is the version number of WordPress. That’s it.
But wait! There’s more…
What else can I do with Subversion? Automattic just released a new branch called Crazy Horse. This branch lets the Automattic team develop and extensively test the user interface design in WordPress like the Write Page, Dashboard and other pages in the Admin. If your a Theme Author or Plugin Developer, you should consider managing your themes and plugins through your own local repository. WordPress was used in this tutorial, but there are tons of other projects you can gain access to via svn.
Common SVN commands for WordPress
svn cohttp://svn.automattic.com/wordpress/trunk .svn cohttp://svn.automattic.com/wordpress/branches/2.5svn cohttp://svn.automattic.com/wordpress/tags/2.5.1svn cohttp://svn.automattic.com/wordpress/branches/crazyhorsesvn cohttp://svn.automattic.com/wordpress/branches/sandbox
Tried of using the command line? Try Versions for mac, or Tortoise for windows.
Want to learn more about subversion? Read the free book online that covers more than you’d imagine.
Let me know if everything worked out for ya in the comments!

July 25th, 2008 at 4:40 pm
I’ve had this bookmarked since you wrote it, and I finally got to use subversion on my new site. Upgrading to decent hosting sure has its benefits. Your instructions were instrumental in making this happen.
Of course, I uploaded the files to the wrong directory twice!
I’ve been using Tortoise SVN for a while to just get the latest versions on my computer, but it’s just nice to be able to get it done on the upcoming site within seconds.
Now, I need to go figure out how to create a subversion repository for my themes.
July 25th, 2008 at 5:11 pm
@Justin Tadlock: That’s awesome, I’m glad it worked out for you in the end!
I also use Tortoise SVN on my laptop, but sadly it doesn’t work for remote locations. But even though using Tortoise SVN makes it a lot easier (visually), for some reason, the command line makes me feel all hacker-ish when I log in remotely! lol it’s weird.
August 2nd, 2008 at 5:55 pm
Thank you