Practical guide to subversion on Windows with TortoiseSVN

by Nikolai Shokhirev

Up: Programming  | Next: Repository backup and restore

Contents

Introduction

There are many excellent books and tutorials on Subversion (SVN) and TortoiseSVN. Some of them are presented in the References section. This tutorial in no way substitutes them. It covers a limited subset of subversion functionality. However, I hope that it simplifies familiarization with SVN.

Subversion is a multi-platform open source version control system (http://subversion.tigris.org/). It consists of a repository database (FSFS or BDB) and several command-line tools. There are GUI front-ends for the Subversion.

The Subversion is designed for project management with several participants. However it can be used to manage personal projects as well.  

The current tutorial is limited to a Windows-based local (without a server) SVN.

 

Subversion installation

Go to the download section of Tigris.org, Open Source Software Engineering Tools ( http://subversion.tigris.org/ ). The latest command-line binaries and libraries for Windows can be found at this location  http://www.open.collab.net/downloads/subversion/. Download the installer. The installation of SVN into the default directory C:\Program Files\Subversion is pretty straightforward. 

At this point you can start using SVN. It is not necessary to install any GUI program if you are comfortable with using command-line tools.

TortoiseSVN installation

TortoiseSVN is a Subversion client, implemented as a windows shell extension, a plug-in to Windows Explorer (http://tortoisesvn.tigris.org/).

The latest version can be downloaded at http://tortoisesvn.sourceforge.net/downloads. For my 32-bit processor I used 32 Bit TortoiseSVN-1.3.5.6804-svn-1.3.2.msi Installer. There is another file, TortoiseSVN-1.3.5.6804-svn-1.3.2.md5 in the download area, which is not required for installation. It contains a checksum of the installer file which is useful if you want to verify that you have downloaded the right installer (and that its not corrupted).

You can download my program HashFile (http://www.shokhirev.com/nikolai/programs/progmisc.html) and verify the installer by checking its MD5 hash (checksum). The checksum must be identical to that found in the TortoiseSVN-1.3.5.6804-svn-1.3.2.md5 file.

This installation is also straightforward, just accept the defaults. The only point of interest is the ASP.Net hack. By default, SVN uses the .svn working directories (Linux style for hidden files).

Default, without the ASP.Net hack

 With ASP.Net hack for VS.Net web projects

This confuses Microsoft ASP.Net and the hack forces SVN to use the  _svn working directories instead. Do not install this feature if you are not going to control your ASP.Net projects by Subversion.

Note, that after installation your Windows Explorer has extra buttons in the main menu 

and in context (activated by right-clicking) menus.

 

Step-by-step setup

There are various ways of Subversion management (see the manuals). Now we consider the most typical scenario: 

In this case you should not worry about security and setting up a server.

Suppose your project resides in C:\Projects\MyProject. It contains files and possibly subdirectories:  

Step 0 (Optional). Global ignore pattern setting. You probably do not want to keep track of temporary and some other types of files. Right-click on any folder, and launch TortoiseSVN/Settings:

 

Alternatively you can click on File/TortoiseSVN/Settings in the Windows Explorer main menu.

In the General section you can list all ignore file types separated by spaces (*.bak *.~* in the above example). Note that this setting affects all working directories. See the section 5.25 of the User Guide for more options.

Step 1. Repository creation. On your hard drive create the directory for repositories of all your projects, e.g. C:\SVN. Create inside it a sub-directory \MyProject. Right-click on MyProject and choose TortoiseSVN/Create repository here:

 Select the default Native FileSystem (FSFS) option and click the OK button:

This converts C:\SVN\MyProject into a repository with the following contents:

So far this is an empty repository, even though Subversion has created several directories and files! We need to fill it with our project files and connect it with our working project directory. All this required several, sometimes counter-intuitive actions.  

Step 2. Initial import. Somewhere in your hard drive (e.g. in C:\tmp) create a directory (e.g. \new) with the following three subdirectories:

     C:\tmp\new\branches
     C:\tmp\new\tags
     C:\tmp\new\trunk

The resulting structure is:

 

This structure is necessary for more advanced project management, but it does not hurt to create it beforehand. Some tutorials first recommend to import this structure into the repository and later add the project. I recommend the following shortcut.

Selelect URL as file:///C:/SVN/Myproject (forward slashes!):

The "Import finished" message shows C:\tmp\new\* :

Do not worry about the "tmp\new" messages, just check what was actually imported into the repository. Right-click on C:\SVN\MyProject and start TortoiseSVN/Repo-browser:

Navigate to file///C:/SVN/MyProject/trunk:

Note that the files from the ignore list were not imported. Also there is no traces of  'C:\tmp\new'. It is no longer useful and it can be deleted.

Step 3. Creating a working directory. Now you have the repository with all your files and the empty C:\Projects\MyProject (remember, we moved all its contents to C:\tmp\new\trunk?). "To get your hands on blessed, completely approved, and fully loaded Subversion directory, you need to check it out from your repository" [6]. Right-click on C:\Projects\MyProject and choose "SVN Checkout":

Set URL to file:///C:/SVN/MyProject/trunk and Checkout directory to C:\Projects\MyProject:

Press OK. Checkout has finished:

The "blessing" is reflected in the small icons on your project directory and all containing files (and subdirectories).

Such a "blessed" directory is called a working directory. Now you can start working with you project and learn more about Subversion.

 

Some remarks

 

References

  1. Subversion Home Page: http://subversion.tigris.org/ 
  2. By Hans Dietrich, Version Control for the Standalone Programmer - Part 1. - Excellent Article at Code Project.
  3. SVN 1-Click setup.- Set up SVN on Windows with a single installer: http://svn1clicksetup.tigris.org/
  4. Adam Pash, How to set up a personal home Subversion server (with Apache on Windows).
  5. RapidSVN, a cross-platform GUI front-end for the Subversion revision system: http://rapidsvn.tigris.org/ 
  6. TortoiseSVN, a Subversion client, implemented as a windows shell extension: http://tortoisesvn.tigris.org/ 
  7. Ben Collins-Sussman, Brian W. Fitzpatrick, C. Michael Pilato. Subversion book: http://svnbook.red-bean.com/ 
  8. TortoiseSVN User Guide, which comes with TortoiseSVN.
  9. Charlie Calvert. Creating Repositories and Projects in Subversion Trunk, Tags, Branches. Codefez: (http://www.codefez.com/Home/tabid/36/ctl/ArticleView/mid/364/articleId/144/Default.aspx)
  10. Sebastian Rahtz. Introducing Subversion, Oxford University: http://www.oucs.ox.ac.uk/oucsweb/svn.xml
  11. An OUCS Guide to TortoiseSVN Client For Windows.http://www.oucs.ox.ac.uk/oucsweb/tortoisesvn.xml
  12. TortoiseSVN Tutorial. http://www.mind.ilstu.edu/research/complete_inactive/iris4/iris40/developers/svntutorial/   
  13. SVN vs CVS. http://www.pushok.com/soft_svn_vscvs.php 
  14. More SVN links
See also: Buildix - The Agile development platform on a disk: http://buildix.thoughtworks.com/.

Buildix includes:

Available as LiveCD and VMWare image.

 

Up: Programming  | Next: Repository backup and restore


Rule

Home | Shokhirev.com | Popular Science | Useful and Useless Programs | ABC Tutorials

Please e-mail me at nikolai@shokhirev.com

©Nikolai Shokhirev, 2004-2007