Shawn Oster (gravatar)

Subversion on Windows with Remote Access

A quick guide to setting up Subversion in Windows and making sure it works from remote locations as well.  There are a few other guides out there but they're all out-dated from what I can tell or they're missing the few things that have bit me in the past.  There is also a great little project called Svn1Click that will get you setup with Subversion, only problem is that it seems to also be out of date, it installs Subversion 1.4.2 and the current is 1.4.5.  So, roll up your sleeves.  I guarantee you'll be able to setup svn faster than it took me to write this thing.

Install Subversion

1. Download latest version of Subversion.  Right now that's version 1.4.5.  You'll want the Windows installer which is svn-1.4.5-setup.exe.

2. Install using defaults.

3. Open a command prompt (Win+R, Cmd, Enter)

4. Check to make sure that Subversion's bin directory was added to your path.  Type "svnadmin help", you should see a list of available svnadmin command.  If not you'll need to add it manually (Right-click My Computer, Properties, Advanced Tab, Environment Variables, System variables,  double-click Path, add ;c:\program files\subversion\bin to end, OK out of all dialogs).

Install TortiseSVN

While not needed to get a svn repository working it's such a rocking way to access your repository you should be using it.

1. Download TortiseSVN (1.4.5 as of this writing) and install it.  Yup, that easy.

Create Repository

1. At a command prompt...

2. Decide where you want your software repository.  Personally I picked the highly imaginative "d:\repository".

3. From the command-line type "svnadmin create d:\repository".  Don't worry if the folder doesn't already exist, the create command will automatically create the folder for you. 

Lock It Down

You'll probably want some security.  Determine who should be able to view it vs. who can commit back to it.

1. Browse to "d:\repository\conf\" and open svnserve.conf.

2. If you're going open-source and anyone can do a checkout but only the chosen can do commits then leave it like it is.  If you're a little more picky over who can see your source then uncomment the "anon-access = read" line and change it to "anon-access = none".

3. Uncomment the "password-db = passwd" line.

3. Save & Close.

4. Open passwd in same folder.

5. Under the users section add your username + password in the form of "username = password".

6. Save & Close.

Running Subversion As a Service

1. Subversion is most useful when you're running it as a service and the nice svn devs have provided a windows service that'll run happily in the background serving up your code.  Type the following into the command-line:

sc create svn binpath= "\"C:\Program Files\Subversion\bin\svnserve.exe\" --service -r D:\repository" displayname= "Subversion Server" depend= Tcpip start= auto

This command line is tricky, two things to remember:

  • Resist your natural urge to clean up the command line, you need exactly one space after the equals of each key pair and no space before it.
  • Since the default install of Subversion installs it in C:\Program Files you need those escaping backslashes in the command-line.  Forget those at your peril.

2. You've created the service, now start it, "net start svn"

3. To access a repository being served by svnserve the url is "svn://<machine name, ip or url here>".  So, to access a repository running locally you can simply do "svn://localhost" (but don't, read the tips below for why).

Is This Thing On?

1. Type "svn info svn://localhost"

2. If you went open-source you'll see some info, otherwise you'll be prompted for your login/password.  Enter it.

3. You'll get back a bit of info on the repository you're now serving.  Sweet.

Accessing SVN from the Road

You probably want to access your repository from more than just your home network so here are a few things you may or may not need to do.

1. If you're like 90% of people you don't have a static IP address to serve your svn repository from.  No problem, go to a service like DynDNS or No-IP.com and get yourself a free dynamic IP domain.  You'll end up with something "mycode.dyndns.org" or "sourceaccess.servehttp.com".  Doesn't matter, get creative, express yourself.  I've used both, no problems with either so it really comes down to which "vanity" domain you like, both have a large selection of domain names you can pick and then you tack your sub-domain onto the front of it.

2. Your repository url is now: svn://yourname.dynamicip.com

3. Now that you have an actual address to use you need to make sure svn traffic actually gets to your computer.  If you have a router you probably need to forward port 3690 to the machine hosting the svn service.  Check your router's manual on how to do this but here is what I do on my NetGear router:

  1. In a browser go to http://192.168.1.1, enter login/password if needed
  2. Look for a section "Attached Devices" or "LAN IP", basically you're trying to figure out the local IP address of the machine running svnserve.
  3. Look for a "Port Forwarding/Port Triggering" section
  4. Add a new Port Forwarding
  5. Name it SVN, select TCP if offered a choice between UDP or TCP.  Selecting both won't hurt anything either.
  6. Port is 3690
  7. Forward to IP is the local IP address of the machine running the svn service.  You should have found this in step 2.  If not you can type "ipconfig" from the command-line and it should show you your current IP address.
  8. OK, Enter, all that stuff, you're good to go.

4. Lastly if you have a firewall it may decide to mess up your day.  There are many firewalls out there but the jist is that you need to allow inbound and outbound traffic on port 3690.  Some programs let you browse to the EXE and allow it, others do it strictly by port.  Some don't block it at all so this step may not be needed.

Advice & Troubleshooting

  • Always use your dynamic address, even at home, even when working on the same machine hosting the repository.  This will save you from having to run the relocate command on your working copies.  First time you go to a coffee shop on your laptop and attempt to connect to your home repository and don't get the "unable to connect to repository svn://home-pc" you'll thank me.
  • If a working svn url suddenly craps the bed and stops working there are usually two reasons, either a) your public IP address has changed and you need to go to your dynamic IP provider and update your IP or b) your machine grabbed a different IP address from your router so now your port forwarding is going to the wrong machine.  Either update your port forwarding or setup a static route in your router to always give your svn machine the same IP.  98% of the time though your svn machine will get the same IP so it's not too much to worry about but it's happened.
  • Add your repository folder to your backup if you're not doing a full system backup.

5 Comments

  • Nope, they are pretty much exactly the same. I just did a remote desktop connection over to my WHS box and did everything from there.One thing I did was create my Repository folder as a shared folder, I wasn't quite sure where to stick it and I figured that was safest, so far haven't had any problems.Hope that helps.

  • Anonymous (gravatar)

    Anonymous said
    February 27, 2008

    Thanks a lot! A big help!

  • Chris&#32;Luebbe (gravatar)

    Chris Luebbe said
    February 27, 2008

    Awesome, thanks. I'll give it a go later in the week.

  • justinlilly (gravatar)

    justinlilly said
    February 27, 2008

    Hey, I just wanted to say thanks a lot for this. It was really helpful!

  • Chris&#32;Luebbe (gravatar)

    Chris Luebbe said
    February 27, 2008

    I saw elsewhere that you managed to install Subversion on WHS. Are the steps really any different than an install on a typical XP Pro machine? How does this affect remote access?Any advice would be helpful as I'll likely be tackling this in a week or two.*subscribes to feed*Thanks!

Your Information
Mrs. Gravatar (gravatar)

<-- It's a gravatar

your comment