This page describes the basic techniques for using the Subversion source control system with Visual Studio.
It is assumed that you already have a Subversion repository that you wish to use. This repo may or may not already have files in it. If you want information about installing the Subversion server on a Windows box, check out my Subversion Cheat Sheet article. Although these days I am partial to using online Subversion hosts like Project Locker.
To use Subversion on your PC then you will probably want to grab both of these Subversion clients:
TortoiseSVN is an svn client that integrates into Windows Explorer. AnkhSVN is a plug-in that tightly integrates with Visual Studio. Just run the installers for both tools; they are very straightforward and will not be described here.
Before jumping into Visual Studio give Tortoise a try. Bring up Windows Explorer then navigate to any directory. Right-click a blank area in the directory listing pane then select TortoiseSVN then Settings from the pop-up menu. There is only one Tortoise setting that you must change in order for Visual Studio and ASP.NET to work properly with Subversion. In this settings window—in the General settings section—be sure that you have Use "_svn" instead of ".svn" directories option selected.
Bring up Visual Studio and have the URL of your repo and name of your solution handy. On the File menu, choose Subversion → Open from Subversion. In the Url field, enter the address of your repo. It may take a few seconds for svn to go out to your repo and populate the window.
Depending on your solution’s structure you may have to double-click a couple of nodes until you get to the solution of your Visual Studio solution’s .sln file. Once you get there, double-click on the .sln file name. This will cause the Open Project from Subversion window to appear.
The From drop-down should be left as it is and you’ll probably want to keep the Type field set to Latest Version and the Append Branch or Tag Name to the Local Directory option unchecked. Lastly, browse to the directory you would like to keep the solution in on your PC and then click the OK button.
The solution will be downloaded from the repo and then Visual Studio will open it. That’s it; you are now ready to add, edit, and delete files in the solution will the full power of source control to help you in your development efforts.
A source control system like svn keeps track of the files you add to, edit in, or remove from a solution. Once a solution has been placed under source control (svn in this case) you will see a new set of icons appear beside each file and directory in your Visual Studio solution.
To modify an existing file in a solution you simply open the file and start typing, just as you always have. The difference is that the svn status icon next to the file will automatically change to an icon that indicates the file has been edited locally and needs to be updated on the server in order for other developers to see your changes.
The biggest benefit to a source control system is that it keeps two developers from modifying the same file at the same time. Well, it doesn’t actually keep this from happening, but it will always tell you if you try to update a file in the repo that was modified by someone else since the last time you updated your copy from the repo.
To create a new file in your solution you right-click the project node or appropriate subdirectory name and then choose Add Item, again as you always have. Once the file is added to the solution then the svn icon for it will be the icon that indicates that this is a new file and must be added to the repo on the server in order for others to see the file.
With a source control system installed (AnkhSVN in this case) and with your solution under source control, you can see an overview of all the files you have changed and/or added since the last time you did a sync with the svn server by using the Pending Changes window. You can show this window by going to Visual Studio’s View menu and selecting Other Windows → Pending Changes.
TBS.
You can also look at your repository outside of Visual Studio’s “view” of the repo. Visual Studio’s Solution Explorer window only shows you the repo files that have been made a part of a solution/project, but the underlying directory of a solution/project may have additional files than just those that are a part of the solution proper. You can see all of the files that are a part of your repo, as well as files that are in other repos, directly from Visual Studio by going to the View menu and selecting Solution Explorer.
The Solution Explorer window is very much like the TortoiseSVN view (see above) of a repo.
TBS.
The article Subversion Best Practices is a great place to start reading about some essential ways to work with svn, including the concepts behind the standard trunk, branches, and tags repo directories, as well as other repo guidelines.