Subversion for absolute beginners

Subversion is a pop­u­lar open-source sys­tem used by soft­ware devel­op­ers, includ­ing the devel­op­ers of WordPress, for version-control. Unfortunately, under­stand­ing Subversion requires delv­ing into the arcane world of ter­mi­nal com­mands. But it’s worth the trou­ble if you’re devel­op­ing a web site or WordPress theme, or even just work­ing on a doc­u­ment, that may need to undergo numer­ous iter­a­tions. Think of Subversion as a kind of per­sis­tent undo that’s even bet­ter than Time Machine.

If you need to col­lab­o­rate 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 arti­cle (i.e., beats me). Fortunately, there are sev­eral free or inex­pen­sive ser­vices that pro­vide easy access to Subversion online. Of these, based on my very quick sur­vey, Beanstalk seems to be the best. You’ll find a quick intro­duc­tion to using ser­vices like Beanstalk in Chris Nagele’s Vitamin post, Subversion for Designers, which also pro­vides a good gen­eral introduction.

If you’re fly­ing solo, the eas­i­est way to use Subversion is to set it up locally on your com­puter. Creating a Subversion server in MAMP or WAMP is unnec­es­sar­ily com­pli­cated, but if you under­stand a few basics, using Subversion locally is sur­pris­ingly easy.

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

Getting Started

Using Subversion is very sim­i­lar to upload­ing and down­load­ing files from your host using an FTP client (for exam­ple, you can use a Subversion client to download—check out—the lat­est WordPress build; see Using Subversion on the WordPress Codex). Whether you’re work­ing remotely or locally, you’ll need a Subversion server and a Subversion client.

Download and install Subversion.

You can get the lat­est ver­sion of Subversion from CollabNet. The lat­est ver­sion 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 excel­lent clients for the Mac are ZigVersion and svnX (both are free for non-commercial use). If you’re a Windows user, try TortoiseSVN.

I pre­fer ZigVersion, so I’ll use it for this tuto­r­ial. After you down­load it, license ZigVersion, then watch the excel­lent video, Introduction to ZigVersion.

Create a repository.

Okay, time to fire up Terminal. You’ll need to set up a new project, called a repos­i­tory, which is where Subversion will main­tain all of your files.

Creating a Subversion repository

  1. First, let’s cre­ate a folder to hold our Subversion projects. In the Finder, cre­ate a new Subversion folder in your Home direc­tory and a sub­folder in the Subversion folder for your project repos­i­tory. For this exam­ple, let’s just name the sub­folder Test.
  2. Launch Terminal.
  3. You should be in your Home direc­tory. Type ls and hit Return to list the files in your cur­rent loca­tion. (For a list of other handy Terminal com­mands, see OS X com­mands.)
  4. Create a new repos­i­tory. 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 num­ber of new files and fold­ers. DON’T TOUCH THESE FILES! From now on, you’ll use your Subversion client to man­age the repository.

Working with Subversion

Now that you have a repos­i­tory, you can start work on your project.

Connect to Subversion

To con­nect to your Subversion repos­i­tory, 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 repos­i­tory in the URL for New Server field. For exam­ple, to access the Test repos­i­tory I cre­ated 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 repos­i­tory is empty, so lets add some files.

  1. If you’re start­ing with a theme or tem­plate (Sandbox, for exam­ple), 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 but­ton and cre­ate a work­ing folder in the Finder. You can now add files to this folder.
  3. After check­ing out the project files, you can double-click them in the ZigVersion win­dow (or in the Finder) to edit them.
  4. If you see a ? in the Status col­umn in the ZigVersion win­dow after edit­ing a file, high­light it, control-click and select Add from the popup menu. Once the file has been added, you’ll see an M in the sta­tus col­umn the next time you edit it, which means the file has been modified.

Check in and review your progress

After edit­ing your files, click the Check In but­ton in the tool­bar to update the changes. You can review the changes and add a com­ment in the Review and Check In win­dow. It’s a good idea to add com­ments so you can remem­ber what you were work­ing on. You can check revi­sions at any time by click­ing on the Revision Viewer button.

Learn More

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

If the ZigVersion man­ual 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 avail­able for free online and you can also down­load a PDF version.

ThemeMeme
Looking for a host that does’t suck? I’ve been with probably 20 different hosts. The best, hands down, is AN Hosting. They offer unlimited storage, unlimited bandwidth, unlimited mySQL databases, unlimited websites, and a free domain for life. Only $5.95/mo! Plus, 3 months free hosting! Sign up with AN Hosting now! Shared hosting not hardcore enough for you? For lightening speed and Digg-proof scalability, check out WP Engine, managed web hosting exclusively for WordPress.

7 Comments on "Subversion for absolute beginners"

  1. sine says:

    Hi — I have tried fol­low­ing these instruc­tions and got into a ter­ri­ble tan­gle… First — zig would not con­nect to my filepath — I was attempt­ing to install locally — but said ‘Expecting FS for­mat 2 found FS for­mat 3′… then as I inves­ti­gated fur­ther, in ter­mi­nal I began receiv­ing svnad­min com­mand not found svn com­mand not found. And although the pack­age installer claims that sub­ver­sion has ben suc­cess­fully installed, I can’t find it any­where. (I’m not sure that I am con­fi­dent enough with Terminal com­mands to know how to find svn resources through it..) Anyway — after four hours of fail­ing to set up sub­ver­sion, i am at my wits end. can you help at all?
    Ta…

  2. Xavier says:

    In response to the com­ment, I’m on a sim­i­lar path to you. However I sus­pect you’ve done what I did and not spec­i­fied the usr/local/bin or what­ever in your path (Please note I don’t fully under­stand any of that but I believe it to be true)-
    Anyway, have no fear — there’s a guide found here;
    http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable
    or try TinkerTool which has an option to view hid­den files in Finder.

    Regarding this instal­la­tion — mine is telling me this;

    svnad­min: Repository cre­ation failed
    svnad­min: Could not cre­ate top-level direc­tory
    svnad­min: Can’t cre­ate direc­tory ‘Subversion/Test’: No such file or directory

    Anyone any ideas?
    Thanks

  3. Xavier says:

    Sorry I got it wrong– sorted now!

  4. walpolpo says:

    I got it worked per­fectly!!! thanks for the guide.…

  5. Ann says:

    Hello, there is a add-on pack­age for MAMP which per­mit you to get Subversion server on MAMP in few clicks. It’s shipped with Trac, a sub­ver­sion source browser,wiki,bug tracker, and Mod_python and python for Python programmers.

  6. person says:

    So many blog posts out there about installing svn!! But I need a run­down of the ter­mi­nal com­mands for con­nect­ing to and inter­act­ing with a remote svn repos­i­tory, sans GUI — why is this so hard to find?

  7. Tenisha Rachel says:

    I like the valu­able infor­ma­tion you pro­vide in your arti­cles. I will book­mark your weblog and check again here reg­u­larly. I am quite cer­tain I will learn a lot of new stuff right here! Good luck for the next!

Got something to say? Go for it!

 
Share be a pal and share this would ya?
Subversion for absolute beginners