Getting Started with Subversion and TortoiseSVN

The purpose of these instructions is to get you started using Subversion (aka SVN) on SE's servers. Your instructor should have set up a team account for you.

These instructions are organized as follow:

  1. Create a shared repository on the SE department's servers
  2. Connect a TortoiseSVN client to securely connect to the repository.
    • Set up Public Keys
    • Checkout a Working Copy
  3. Step through an everyday workflow with SVN

I. Repository Setup

This part should be done ONCE, by just one team member.
  1. Use PuTTY to SSH to control.se.rit.edu using the team account provided by your instructor.
  2. Issue exactly the following commands from the team account's home directory. In the second command, note that those are backticks, not single quotes. (To paste text into PuTTY, use Shift+Insert, or right-click with the mouse)
    svnadmin create svn
    svn mkdir -m "Creating trunk folder" file://`pwd`/svn/trunk 
    chmod -R g+rwx,o-rx svn
    				

II. TortoiseSVN Setup

All team members will need to do this part.

We will be connecting to our SVN repository using the Secure Shell (SSH) protocol. The most secure and convenient way of accomplishing this connection with public keys. So first, we will need to set up Windows to connect to our server via SSH public keys.

II.a Set Up Public Keys

If you have already set up a public key with PuTTY, Pageant, and control.se.rit.edu , just skip this step and use that key.
  1. Download and install puttygen.exe and pageant.exe (either download them individually, or use the Windows installer)
  2. With puttygen.exe. Generate a new key. Set a passphrase for unlocking this key (can be anything you want). Write a useful and write a useful name in the "Comment" field. Keep this window open.
  3. Save your public key and your private key. Name the files after your computer, like "laptop.pub" and "laptop.ppk". Still keep this window open. (SECURITY NOTE! As the word "private" implies, this ppk file should never be shared with anyone, otherwise they can spoof your entire SE account if they guess the passphrase.)
  4. Copy the public OpenSSH key in the text box from PuTTYGen.
  5. Use PuTTY to SSH into control.se.rit.edu, as yourself (not as your team user).
  6. From the command line, create a folder in your home directory called .ssh. The command is:
    mkdir .ssh			
    			
  7. Now create and edit a file in .ssh called authorized_keys. Paste that OpenSSH public key into your authorized_keys. You will need a command-line text editor to do this. Here's how to do it in vi:
    vi .ssh/authorized_keys
    			
    Then within vi, press i to enter edit mode. Hit Shift+Insert to paste the public key in. Press ESC, then type :wq (note the colon - this command stands for "write" then "quit").
  8. Close the PuTTY window and the PuTTYGen window.
  9. At this point, the control SSH server knows that whomever shows up with a private key matching this public key, control will authenticate them as you. To provide this public key, we need Pageant. (Pageant is the PuTTY SSH Agent.) Run pageant.exe. This is a very lightweight program that shows up in your system tray once you run it.
  10. Add your key to the agent by right-clicking on the agent below and adding your key.
  11. You can see that your key is added. In the "View Keys" menu:
  12. Let's test our key. Use PuTTY to sign into control.se.rit.edu as yourself, only this time, you should not have to enter your password.

II.b Checkout a Working Copy

All team members will need to do this part.

Once you have Pageant running with your key loaded, you'll need to check out a working copy of the repository to your local machine.

  1. Open up the directory where you want to store the your project.
  2. Right-click on the directory and click "SVN Checkout"
  3. When prompted, enter the path to the team repository created above. The URL looks like this:
    svn+ssh://abc1234@control.se.rit.edu/home/teams/610/x610-0yz/svn/trunk
    			
    Your URL will differ, however:
    • abc1234 is your personal SE account
    • 610 is the course number
    • x610-0yz is your team account (e.g. f610-01a for Fall 610, Section 01, Team A)
  4. Your checkout window might look something like this. The defaults are usually okay. Note: If this is a new project, you will not see any project files. If you have hidden folders turned on, you may see a .svn folder.

III. Basic Workflow with Subversion

  1. Now let's go through some everyday steps with Subversion. Let's start by checking in a file. Create a file called "HelloWorld.txt"
  2. Once the files is saved, you can move back to the parent folder and select to commit the changes we just made to the project. (You may also right click on a specific file to add, then commit). Go to SVN Commit, and type in a useful commit message.


  3. Have another teammate perform the project creation steps.
    • They should retrieve the HelloWorld.txt file.
    • The student should then add their own name to the file.
    • Save the file.
    • Commit those changes back into the repository.
  4. The next step is to make sure that you can retrieve your teammate's changes. Right-click the directory or file and select "SVN Update"
  5. You may also view the history of a file or directory and even revert back to previous versions of a file. One way of doing this is to right click on the file or directory you wish to examine and select TortoiseSVN->Repo Browser.
  6. You may then right click the file you wish to examine and select one of many options. One is show log. Doing this will display the history of the file and all commit messages. This is one reason why it is so important to commit files with appropriate messages. Doing so will make a much more informative history viewing experience.
  7. You should also review external tutorials on Branching & Tagging, and Merging

Helpful Tips