As noted in a previous post, I'm now using Subversion (SVN) for source code control of my mobile blogging app (along with a couple of other projects sitting on my hard drive). Here's a quick "how to" on getting Subversion running under Windows XP with VS.NET integration.
1. Download TortoiseSVN. As the website says, it's the coolest interface to SVN (to be accurate its both SVN and an SVN client all-in-one). The download page has installers for both 32-bit and 64-bit. Please make sure you download the correct one. :)
2. Install TortoiseSVN. It's a windows shell extension so you'll have to reboot after installing.
You're done. No really. That's pretty much all there is to getting Subversion running on your machine. After rebooting, you can create your first repository with just a few mouse clicks. In this example, I created a "SVN_Repositories" folder on my F:\ drive. In that folder, I right-click, select "TortoiseSVN" and then "Create Repository Here...":
When asked for type of repository, select "Native Filesystem (FSFS)". I've been told the Berkeley DB version is a little buggy. That should be the default:
You should now be greeted with a dialog indicating that your repository has been created:
The folder now contains a bunch of folders and files. This is all of the structure that defines your repository. This is not an area you'll spend much (if any) time in. It's just a datastore for Subversion.
If you want to see what's in this repository you just created, right-click while in any Windows Explorer window and select "TortoiseSVN" and then "Repo-Browser" (short for "Repository Browser"):
You'll now need to provide a URL for where the repository is located (subversion supports many protocols including http://, https:// and file://). For my example, I pointed it to my F:\SVN_Repositories folder (note the use of "/" in the folder path instead of the traditional Win32 "\". We're typing in a URL remember):
Our repository browser opens up and shows that the repository is empty -- which is expected since it is brand new!
At this point, you can add files or entire folders into the repository. You could import an existing VS.NET solution by just right clicking on the solution folder and selecting "TortoiseSVN" and then "Import...". However, this is a recursive operation that would bring everything into the repository -- including things you don't want like the "bin" and "obj" folders (no need to version control these since they are built from the source). To make this really easy, we'll get AnkhSVN -- the Visual Studio.NET addin that adds Subversion integration.
There's two ways to get AnkhSVN:
1) Download and compile the source. This is quite easy since you've got TortoiseSVN. All you need to do is create a working directory for the source to be stored in and use TortoiseSVN to do a "Check out" over an http:// URL (if you're familiar with Visual SourceSafe, an SVN "Checkout" is the same thing as a VSS "Get Latest" -- no locking happens). However, the AnkhSVN source requires that you have included the C++ compiler when you installed VS.NET. If you're like me ("I'll never need that!"), you don't have the C++ compiler installed. On to option #2.
2) Download a precompiled MSI installer. I chose the RC4 candidate of version 1.0 which was released October 28, 2006.
Installing AnkhSVN is straightforward: close all instances of VS.NET and run the MSI installer. No reboot is required.
Now lets get a project under version control! For this example, I've created the canonical "Hello, world" C# console application:
To add this to our new repository, right-click on the Solution File in Solution Explorer and select "Ankh" and then "Add solution to Subversion repository...":
A dialog will pop up asking you to provide the location of the Subversion repository. Again, I'll use the URL to my F:\SVN_Repositories directory:
You also have the option to create a subdirectory for this solution. This is handy when you're going to be adding multiple solutions to a single repository.
Once you click OK, a progress dialog will be displayed as your solution is added to your Subversion repository. When this is done, you'll notice a little green checkmark next to all of your source files in Solution Explorer:
This tells you that the files are under version control and that they match what is in your repository. Now I'll make a small change to the source code:
static void Main(string args)
I save my changes and now Solution Explorer will now show a small red mark next to Program.cs and the HellowWorldCS project. This indicates that your local file no longer matches what is in the repository:
To place these changes into our repository (thus creating a new version), you can either right-click on an individual file to update (like Program.cs) or right-click on the entire project (or even the entire solution). Select "Commit..." from the menu:
A dialog box will pop up allowing you to place comments with this commit. This is helpful to document the changes you've made:
Click "Commit" and a progress dialog will display as your changes are committed to the repository. Solution Explorer will now display the green checkmarks next to your files since everything is up to date!
This post just scratched the surface of using Subversion -- or using source control in general. There's version history, branching, diff'ing -- lots and lots of stuff to learn to harness the power of version control. Play around with Ankh and SVN and you'll find that having some version control in your development (even if you're just a single developer) comes in handy when you need to revert back to an older version or patch a release.