Saturday, July 14, 2012

Setting up SVN on Windows

Source and version control is a very useful thing to use for any developer, even on an individual level. It is surprisingly easy to set up. The following two links provide the necessary steps to set up an SVN server on a Windows environment:

http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html
http://willperone.net/Code/svnserver.php

In short, it boils down to installing the Win32 SVN server, configuring access control, and creating a repository. The step about setting up a service is optional - you can just run the server when needed, using:

svnserve -d -r RepositoryName

On the client side, all you need to do is install TortoiseSVN and set up your project folders. Designate a new folder (e.g. "projects" or "sources") to contain all your SVN projects. Then do an SVN Checkout inside that folder, and try your first commit. The path to connect to looks like this:

svn://machinename/ .

If you want multiple repositories for unrelated sets of projects, just organise them that way on the client side before you start committing. For example, you can have a directory structure that looks like this:

C:\sources\java\MyFirstJavaProject
C:\sources\java\MySecondJavaProject
C:\sources\cs\MyFirstCSharpProject
C:\sources\cpp\MyFirstCPlusPlusProject
C:\sources\cpp\MySecondCPlusPlusProject

Problems that are easy for newbies (such as myself) to run into include connection and authorisation issues. If you can't connect, or can't find the repository, then make sure the SVN path is as described above, the service is running, and that port 3690 is open in your firewall. Authorisation issues always relate to the svnserve.conf and passwd files, which are located in the conf folder of the repository.

For those concerned about retention of history and data for backup purposes or when eventually moving the SVN server to a different machine, check out the svnadmin dump and load subcommands, illustrated in the following article:

http://www.petefreitag.com/item/665.cfm