To start, download Subversion
and Tortoise SVN
. Install Subversion, and then install Tortoise SVN. If you want Visual Studio integration, check out VisualSVN
($49.00) or the free Ankh tool
Tortoise works as a front-end UI to Subversion. They are version-dependent, so you should always install the latest version of each.
|VisualSVN integrates with Visual Studio, but uses Tortoise for most of its UI.|
I'll walk you through the process of creating a new repository and adding a Visual Studio Solution with a couple of projects to it.
If you are not setting up a new repository and just need to create a local copy from Subversion repository, just skip ahead to the Creating a Local Copy
Configuration for Tortoise SVN
Before doing anything else, I suggest you make one small configuration change in Tortoise SVN—change the name of the local SVN repositories from .svn
. Visual Studio has issues with folders that start with a period so it's best to use the _svn
prefix, especially if you decide later on to use a tool that integrates with Visual Studio.
|Figure 1. Tortoise SVN Settings General Tab: It's a good idea to set up Tortoise SVN to use _svn instead of .svn, because Visual Studio has issues with directories that start with a period.|
Make sure you've installed Tortoise SVN. Go into Explorer and right-click anywhere on a file or folder. On the shortcut menu, choose TortoiseSVN, then choose Settings and check the "Use '_svn' instead of '.svn'" check box on the General tab as shown in Figure 1
Create a New Repository with Tortoise SVN
Now you're ready to create a new repository. The repository is a storage location on disk where Tortoise SVN stores all the versioned data. You can store the repository on your local machine or a remote server where users can access it either through the Subversion Daemon service or through HTTP via an Apache module (a separate install). The key is that you need to create the repository on that machine.
To create a repository, create a main folder for your main Subversion repository. I prefer to use a top-level folder so it's easy to find and back up. So choose something like d:\subversion
and do the following:
- Create the folder d:\subversion.
- Right-click TortoiseSVN and choose "Create repository here."
- Set up permissions for this repository.
To set up permissions, you need to configure d:\subversion\conf\svnserve.conf
and set a password.
# anon-access = read
auth-access = write
password-db = passwd
realm = SummaLp
This configuration enables only authenticated access to the repository, provides write access for authenticated users, and no access for anonymous users.
Next, edit the password file (password
with no extension) and add any names you want to allow as key value pairs. For example:
Setting Up to Run Subversion as a Service
ricks = wonkiewind
billp = haggard
With the repository created, the next step is to make it accessible remotely. Subversion comes with a built-in Daemon server that can serve your repository data over a TCP/IP connection (port 3690 by default). Alternatively, you can use Apache and an Apache module to connect to the repository over HTTP. The TCP/IP service is native to Subversion and is easiest to set up. It's also faster than the HTTP integration. However, the HTTP integration runs through Apache and offers better security and authentication, as well as access through port 80. This article describes only how to use the TCP/IP Daemon service.
The file BIN
directory of the Subversion installation provides the service. While you can run the .exe
file explicitly to start the server you'll definitely want to install it as a service instead. To do this, you can run the following command line (I suggest putting it in a batch file—all on one line!):
sc create svn binpath= "\"c:\program
displayname= "Subversion Server"
depend= Tcpip start= auto
|Make sure the paths in the preceding command match your installation and repository paths. Also, note the spaces in the command line! They are not optional—I had trouble getting things to work until the spaces were added.
If you want to use a different port add: listen-port=nn
is the port ID. Check for other options in the documentation.
To start the service through the Service Manager or from the command prompt, use the command:
sc start svn
You should only have to do this once; if you installed the service using the command shown above, the service should auto-start the next time you start Windows.
Check the Repository
To make sure the repository works, launch Tortoise SVN from anywhere and try to connect to your IP address or host name. Simply open Explorer, right-click, and from the shortcut menu choose TortoiseSVN and then choose "Repo-browser." Type in svn:///
and you should land at your repository. If you installed the repository on a remote machine, use its IP address or domain name.
Open the repository by double-clicking the node. If you get an error message, the repository is not accessible. If you opened the repository from a local machine, this should definitely work. If it doesn't, make sure your repository and the path specified for the service start-up match. For a remote repository, make sure that the port the server is running on is open in your firewall and your server's firewall. The default port is 3690.
When you can open the repository without errors, you are set up for shared source control with Subversion.