Subversion and TortoiseSVN on Windows

Assuming you have downloaded TortoiseSVN and installed it in Windows 7, the following shows examples of how to access and use your SVN repository. The examples use the user u5000000000. You need to use your own username and password.

Create a Directory for your Repository

Create a directory (folder) to store the contents of your SVN repository. It can be named and located where you like. In the example above I've created a directory named after my repository name, i.e. u5000000000, inside by Documents library, i.e. C:\Users\sgordon\Documents\u5000000000.

SVN example

Checkout The Repository

Right-click on the newly created directory and select SVN Checkout... from the context menu. You normally only perform a checkout on your computer once, when you start using the repository. It copies the structure and files of the repository on the server to your computer. The copy on your computer is called the working copy.

SVN example

Enter the URL of your repository. Each student has a repository named after their username, e.g. Alternatively, if you want to access the projects repository instead of your own private repository use or to access a specific directory Note the S in https - everything sent to/from the server is encrypted.

SVN example

The first time you access the server you may be presented with a security warning. This is because on the IT server a self-signed certificate is used. You either need to trust that it is a valid certificate or contact me to confirm the fingerprint.

SVN example

Enter your username and password if prompted. It is the same as for your IT server account.

SVN example

The checkout proceeds. The files from the server are downloaded to your computer. In this case it is very fast as there are currently no files on the server, i.e. at Revision 0. Once finished, click Ok. Note carefully if there are any warnings or errors, usually in red text. Maybe you entered the URL ( wrong or do not have a network connection to the server.

SVN example

If everything worked correctly you should see a green circle with a tick on your newly created directory (possibly you need to refresh to see it). This green tick indicates that the directory contains part of a SVN repository and your working copy is currently up-to-date with respect to the server copy. You can now use the directory as you wish (e.g. creating files and directories within it).

SVN example

Commit a File to the Server

Lets say you have edited some files/directories (inside your newly created directory) and want to upload them to the server. This is called a commit. I've created a single file example.txt.txt (the double .txt extension is a mistake by me - I'm not used to Windows).

Right-click on the newly created file (or directory) and from the TortoiseSVN menu select Add. This effectively registers the file with SVN on your computer (by default the file is just a normal file - you need to explictly tell SVN to store it in the repository).

SVN example

Once added, a small icon with a plus sign will be shown on the file. Note that the file is not yet stored on the server.

SVN example

Going up a directory you'll see the icon on your repository directory has changed from a green tick to a red circle with an exclamation mark! This means there is something in your working copy on your computer that hasn't been committed to the server yet.

SVN example

Commit the file or directory to the server by right-clicking and selecting SVN Committ.... Note you can commit individual files or entire directories (and all directories and files within it).

SVN example

Before the commit occurs you are given the opportunity to enter a log message. It is good practice to enter a meaningful message. Then press Ok.

SVN example

The commit proceeds: your computer uploads the changed files (in this examle, the entire new file) to the server. The revision number is incremented.

SVN example

Once again the repository directory has the green tick.

SVN example

Checkout and Commit from Another Computer using Linux

One of the benefits of using SVN is that you can access your repository from different computers. In the steps above the repository was checked out in Windows on my desktop computer. Now I will checkout the repository and make some changes on another computer. And to make things interesting, this will be performed on the command line in Ubuntu Linux. The commands I type are shown in bold.

Checkout the repository:

sgordon@lime:~$ svn co --username u5000000000
Authentication realm:  SVN repository for u5000000000
Password for 'u5000000000': mypassword
A    u5000000000/example.txt.txt
Checked out revision 1.

I supplied my username, u5000000000, in the checkout (co) command and was prompted for my password. Then all the files in the server respository were downloaded to my computer. My working copy is in the directory u5000000000 (which was automatically created). To check I can use ls:

sgordon@lime:~$ cd u5000000000/
sgordon@lime:~/u5000000000$ ls -l
total 4
-rw-rw-r-- 1 sgordon sgordon 26 Jul  2 11:34 example.txt.txt
sgordon@lime:~/u5000000000$ cat example.txt.txt
This is the first example.

Now lets change the existing file by adding a new line of text to the end. You can use any text editor (nano, gedit, emacs); in the example below to keep it on the command line I'll use echo:

sgordon@lime:~/u5000000000$ echo "Edit the existing file" >> example.txt.txt
sgordon@lime:~/u5000000000$ cat example.txt.txt
This is the first example.
Edit the existing file

And lets create a new file:

sgordon@lime:~/u5000000000$ echo "A new file" > newfile.txt
sgordon@lime:~/u5000000000$ cat newfile.txt
A new file

The new file needs to be added to SVN:

sgordon@lime:~/u5000000000$ svn add newfile.txt
A         newfile.txt

Now I need to commit the changes to the server:

sgordon@lime:~/u5000000000$ svn commit

A text editor (e.g. nano) will be opened allowing you to enter a message before the commit takes place:

Edited the example
Added a new file
--This line, and those below, will be ignored--

M    example.txt.txt
AM   newfile.txt

And the commit proceeds, uploading the new files and the changes to existing files to the server:

Sending        example.txt.txt
Adding         newfile.txt
Transmitting file data ..
Committed revision 2.

Update the Working Copy using Windows

Now back to my original computer running Windows. I know that changes have been made to the server. So I want to update my local working copy. Right-click on the repository directory and select SVN Update:

SVN example

The differences between the server copy and the working copy are downloaded to your computer:

SVN example

Looking in my directory I can now see the new file:

SVN example

In summary, after checking out a repository the main commands used are commit to upload your changes to the server, and update to download the latest versions on the server to your working copy.

Other SVN Features: Viewing Difference Between Versions

SVN has many other features. In Windows they can be find from the TortoiseSVN menu when you right-click on a file or directory.

One example feature is to see the difference between files of different versions (not useful for binary files). Right-click on the example.txt file and select Diff with previous version:

SVN example

A new window is opened. On the left is revision 1 of the file and on the right the current version in the working copy:

SVN example

TortoiseSVN in Windows and svn on the command line in Unix-like operating systems (Linux, MacOS) give you access to all features of SVN. But sometimes you just want to view/download files in your respository. On the IT server we are using ViewVC to provide a read-only access to your repository. Visit and select your repository and then you can access all your server files (even if you don't have TortoiseSVN installed).

You can read about all the features of SVN via the free, official SVN book.

Go back to the index page.