Using Subversion

From New IAC Wiki
Revision as of 22:15, 28 September 2010 by Oborn (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Subversion (commonly referred to as SVN) is a source-code control system. It can keep track of files, their history over time, and when different users change them. It's designed to keep track of data to answer questions like:

  • When was this section added?
  • Who made modification X?
  • What did this file look like when I used it 3 months ago?


Using SVN from the command line (Linux or cygwin)

Using ssh-agent is highly recommended to avoid annoying password prompts all the time while still keeping the server relatively secure.

One-time setup

On each client, create a password-protected ssh key:

oborn@winnebago:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oborn/.ssh/id_rsa): 
Created directory '/home/oborn/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/oborn/.ssh/id_rsa.
Your public key has been saved in /home/oborn/.ssh/id_rsa.pub.
The key fingerprint is:
0d:77:74:1c:3d:c5:45:ba:1c:05:88:1e:af:c8:b0:79 oborn@winnebago
The key's randomart image is:

Make sure to enter a password different from your server password for the password fields. Next copy the key to devsource.

oborn@winnebago:~/.ssh$ scp ./id_rsa.pub oborn@134.50.3.139:.ssh/client.pub
oborn@134.50.3.139's password:
id_rsa.pub

SSH into devsource and append the key to authorized_keys:

oborn@winnebago:~/.ssh$ ssh 134.50.3.139
oborn@134.50.3.139's password: 
Linux devsource 2.6.32-24-server #43-Ubuntu SMP Thu Sep 16 16:05:42 UTC 2010 x86_64 GNU/Linux
Ubuntu 10.04.1 LTS
Last login: Tue Sep 28 01:39:22 2010 
oborn@devsource:~$ cd .ssh/
oborn@devsource:~/.ssh$ cat client.pub >> authorized_keys 
oborn@devsource:~/.ssh$ exit
logout
Connection to 134.50.3.139 closed.

Setup for each client console that you will use svn in

Start ssh-agent:

oborn@winnebago:~$ eval `ssh-agent`
Agent pid 28009

Add the ssh-key to ssh-agent:

oborn@winnebago:~$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /home/oborn/.ssh/id_rsa: 
Identity added: /home/oborn/.ssh/id_rsa (/home/oborn/.ssh/id_rsa)

Enter the password you used when creating the key, not the password for the server.

And test the ssh connection:

oborn@winnebago:~$ ssh 134.50.3.139 hostname --long
devsource.iac.isu.edu

This should not prompt for a password (ssh-agent and your key will provide security).


SVN commands

The basic structure of the URL for repository access is:

svn+ssh://user@server/path/

For example, to log in as "brian" on devsource.iac.isu.edu and access the homework directory:

svn+ssh://brian@devsource.iac.isu.edu/home/brian/svn/homework/407/

The svn list command lists the files in a repository:

svn list svn+ssh://brian@134.50.3.139/home/brian/svn/homework/407/
406_template.pdf
406_template.tex
407_HW1.pdf
407_HW1.tex
407_HW1_soln.pdf
407_HW1_soln.tex
407_HW2.pdf
407_HW2.tex
407_HW3.pdf
407_HW3.tex
mod_1.2.cpp
mod_1.3.cpp
mod_1.4.cpp
mod_1.5.cpp
mods
mods.cpp