Skip navigation

Version Control

Getting Started with AnkhSVN and Subversion

asp:Feature

 

Version Control

Getting Started with AnkhSVN and Subversion

 

By Alexey Smirnov

 

There are a few version control solutions for ASP.NET out there on the market. One of them is a new version of AnkhSVN. AnkhSVN 2.0 is a free Subversion client, implemented as a package for Microsoft Visual Studio 2005 and 2008. It provides an interface to perform the most common revision control operations directly from inside the VS.NET IDE.

 

This article provides an introduction to AnkhSVN by describing how the product works and explaining its main operations.

 

As mentioned above, AnkhSVN is a Subversion client; in other words, an interface between Subversion, a free open-source version control system, and Visual Studio .NET. On its own, Subversion allows one to track and store code changes, collaborate, and share project files. All information about project files is saved to a repository, a simple directory structure. To create and manage a repository you would need to install Subversion or one of several other third-party client applications. For this purpose, this article used TortoiseSVN, a standalone Subversion client.

 

There are many good reasons for AnkhSVN and TortoiseSVN cooperation. While TortoiseSVN has all the necessary commands to work with Subversion and can be used as a standalone version control tool, AnkhSVN focuses on automating common tasks for Visual Studio developers and integrating to the IDE. Used together, both tools can provide everything needed to make the development process quick and easy.

 

The most recent versions of AnkhSVN and TortoiseSVN can be found on their official Web sites: http://www.ankhsvn.com and http://www.tortoisesvn.net.

 

Once AnkhSVN and TortoiseSVN have been downloaded and installed, it is required to create the initial repository. To accomplish this, first create a new folder. TortoiseSVN extends Windows Explorer and all commands are available from its context menu. Right-click on the new folder and access the TortoiseSVN menu. Select the Create Repository Here option.

 

Start Visual Studio and make sure AnkhSVN is the active source control provider. Open Tools | Options | Source Control and check that AnkhSVN is already selected.

 

Open a project in VS.NET. From File Menu | Subversion | Add add the solution to Subversion. In the Add to Subversion dialog box add the Repository URL created in the previous step. For a directory located at D:\SvnRepos the URL will be file:///D:/SvnRepos/.

 

After that you ll see in Solution Explorer a blue plus sign (+) next to each file. This means your files are ready to work with Subversion. To add files in the repository, open the context menu in Solution Explorer and click Add, then click Commit. You ll see green checkmarks alongside items in Solution Explorer. Now your project is under version control and the initial version of the project is saved in the repository.

 

AnkhSVN adds to Visual Studio a new Pending Changes window to show all changes in a single location rather than having to navigate through Windows Explorer or even Solution Explorer. Once you start to make changes, you ll see modified items added to the Pending Changes window. This window is accessible through View | Show Pending Changes.

 

If a project has been modified and new revisions were added in a repository, you can restore the revisions by using Update and View History in the context menu of Solution Explorer. To restore the previous version, go to Update | Revision | Previous. To get back to the specific revision, open View History and find the number of the revision you want to get back. Then open Update and specify the number to get the right revision.

 

Update and View History can be applied concurrently to multiple files. To restore a single file you may use Revert to get the revision menu from Solution Explorer.

 

You ll get a more advanced interface to work with the repository in TortoiseSVN. Go to Windows Explorer. In the context menu find TortoiseSVN | Update to revision, where you can choose which revision has to be restored in the project directory.

 

One of the features of a version control system is the ability to isolate changes onto a separate line of development. This line is known as a branch. Branches are often used to try new features without disturbing the main line of development with compiler errors and bugs. As soon as the new feature is stable enough, the development branch is merged back in to the main branch (trunk). Another feature of a version control system is the ability to mark particular revisions (e.g., a release version) so at any time you can recreate a certain build or environment. This process is known as tagging.

 

Subversion combines these two processes into one. Create Branch/Tags is available in TortoiseSVN through the context menu Branch/Tags. Specify the URL for the new branch; for example, project_url/1.0 where 1.0 will be the name of the branch. Use the Switch working copy to new branch/tag checkbox if you want your working copy to be switched to the newly created branch.

 

After that you can work on the project as usual and when you need to return the whole project back to version 1.0, use the Update to revision command.

 

Conclusion

The new release of AnkhSVN is fast and stable compared to the earlier versions and a good alternative to other source control solutions for ASP.NET developers. This article covered typically used commands of AnkhSVN and explained main steps to start working with AnkhSVN and Subversion. More information about Subversion and other third-party clients can be found at http://subversion.tigris.org.

 

Alexey Smirnov is an IT consultant and a Microsoft MVP. You can reach him at mailto:[email protected].

 

 

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish