Subversion for absolute beginners

4 Flares 4 Flares ×

Subversion is a popular open-source system used by software developers, including the developers of WordPress, for version-control. Unfortunately, understanding Subversion requires delving into the arcane world of terminal commands. But it’s worth the trouble if you’re developing a web site or WordPress theme, or even just working on a document, that may need to undergo numerous iterations. Think of Subversion as a kind of persistent undo that’s even better than Time Machine.

If you need to collaborate on projects using Subversion, you’ll have to have access to an online Subversion server. Setting up a Subversion server online is beyond the scope of this article (i.e., beats me). Fortunately, there are several free or inexpensive services that provide easy access to Subversion online. Of these, based on my very quick survey, Beanstalk seems to be the best. You’ll find a quick introduction to using services like Beanstalk in Chris Nagele’s Vitamin post, Subversion for Designers, which also provides a good general introduction.

If you’re flying solo, the easiest way to use Subversion is to set it up locally on your computer. Creating a Subversion server in MAMP or WAMP is unnecessarily complicated, but if you understand a few basics, using Subversion locally is surprisingly easy.

Here’s a quick tutorial on how to set up Subversion locally on your Mac (using Subversion on Windows should be similar).

Getting Started

Using Subversion is very similar to uploading and downloading files from your host using an FTP client (for example, you can use a Subversion client to download—check out—the latest WordPress build; see Using Subversion on the WordPress Codex). Whether you’re working remotely or locally, you’ll need a Subversion server and a Subversion client.

Download and install Subversion.

You can get the latest version of Subversion from CollabNet. The latest version for Mac OSX as I write this is Universal Subversion 1.4.6. Download and run the Subversion installer.

Download and install a Subversion client.

You don’t want to do any more than you have to from Terminal, so you’ll need a Subversion client. Two excellent clients for the Mac are ZigVersion and svnX (both are free for non-commercial use). If you’re a Windows user, try TortoiseSVN.

I prefer ZigVersion, so I’ll use it for this tutorial. After you download it, license ZigVersion, then watch the excellent video, Introduction to ZigVersion.

Create a repository.

Okay, time to fire up Terminal. You’ll need to set up a new project, called a repository, which is where Subversion will maintain all of your files.

Creating a Subversion repository

  1. First, let’s create a folder to hold our Subversion projects. In the Finder, create a new Subversion folder in your Home directory and a subfolder in the Subversion folder for your project repository. For this example, let’s just name the subfolder Test.
  2. Launch Terminal.
  3. You should be in your Home directory. Type ls and hit Return to list the files in your current location. (For a list of other handy Terminal commands, see OS X commands.)
  4. Create a new repository. Type svnadmin create Subversion/Test and hit Return.
  5. You’re done with the Terminal (yea!), so you can close it. Open the /Subversion/Test folder in the Finder and you’ll see a number of new files and folders. DON’T TOUCH THESE FILES! From now on, you’ll use your Subversion client to manage the repository.

Working with Subversion

Now that you have a repository, you can start work on your project.

Connect to Subversion

To connect to your Subversion repository, launch your Subversion client. If you’re using ZigVersion, you’ll see the Connect to a Server window.

ZigVersion Connect to Server window

Enter the path to your repository in the URL for New Server field. For example, to access the Test repository I created above, I would enter: file:///Users/robert/Subversion/Test. You’ll need to replace robert with the name of your Home directory.

Add and edit files

The repository is empty, so lets add some files.

  1. If you’re starting with a theme or template (Sandbox, for example), just drag the theme folder to the ZigVersion window.

    Viewing the repository in ZigVersion

  2. If you want to start with an empty project, click on the root folder, then click on the Check Out button and create a working folder in the Finder. You can now add files to this folder.
  3. After checking out the project files, you can double-click them in the ZigVersion window (or in the Finder) to edit them.
  4. If you see a ? in the Status column in the ZigVersion window after editing a file, highlight it, control-click and select Add from the popup menu. Once the file has been added, you’ll see an M in the status column the next time you edit it, which means the file has been modified.

Check in and review your progress

After editing your files, click the Check In button in the toolbar to update the changes. You can review the changes and add a comment in the Review and Check In window. It’s a good idea to add comments so you can remember what you were working on. You can check revisions at any time by clicking on the Revision Viewer button.

Learn More

If you’re using ZigVersion, you’ll learn everything else you need to know in the Introduction to ZigVersion video and the
Getting Started With ZigVersion manual.

If the ZigVersion manual isn’t enough, take a look at Version Control with Subversion, the book on Subversion and, trust me, more than you want to know. The entire book is available for free online and you can also download a PDF version.

Comments
  1. sine
  2. Xavier
  3. Xavier
  4. walpolpo
  5. Ann
  6. person
  7. Tenisha Rachel

Post A Comment

Your email address will not be published. Required fields are marked *

 
4 Flares Twitter 1 Facebook 3 4 Flares ×