Example SVN Repository Checkout

From wiki.ucalgary.ca
Jump to: navigation, search

Example SVN Repository Checkout

The following is an example of accessing my svn repository on the submission server. This example command line interaction assumes that my repository has already been set up via svn import or some other mechanism (this has been done for you; both individual and team repositories have been seeded with a default structure).

It also assumes that you have loaded the correct ssh private key into your local ssh agent.

[michael@xorenduex ~]$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /Users/michael/.ssh/id_rsa: 
Identity added: /Users/michael/.ssh/id_rsa (/Users/michael/.ssh/id_rsa)
[michael@xorenduex ~]$ ssh-add -l
1024 ad:75:c0:a4:3e:c5:25:e2:75:6d:0c:c7:82:63:14:c7 /Users/michael/.ssh/id_rsa (RSA)

I first make a directory on my local machine. I like ~/svn to hold all my svn working copies for all projects. Within 'svn', I make a new directory for CPSC457.

[michael@xorenduex ~]$ mkdir svn
[michael@xorenduex ~]$ cd svn
[michael@xorenduex svn]$ mkdir CPSC457
[michael@xorenduex svn]$ cd CPSC457
[michael@xorenduex CPSC457]$

I then use the 'svn list' command to see what is at the repository URL on the remote server.

[michael@xorenduex CPSC457]$ svn list svn+ssh://locasto@ec2-50-19-41-44.compute-1.amazonaws.com/home/locasto/repository
README
branches/
tag/
trunk/

I then do a checkout of the remote repository to place a local working copy on my local machine in this directory.

[michael@xorenduex CPSC457]$ svn co svn+ssh://locasto@ec2-50-19-41-44.compute-1.amazonaws.com/home/locasto/repository
A    repository/trunk
A    repository/branches
A    repository/tag
A    repository/README
Checked out revision 1.
[michael@xorenduex CPSC457]$ ls
repository/
[michael@xorenduex CPSC457]$ cd repository/
[michael@xorenduex repository]$ ls
README		branches/	tag/		trunk/
[michael@xorenduex repository]$ ls trunk
[michael@xorenduex repository]$ cd trunk
[michael@xorenduex trunk]$ mkdir hw1
[michael@xorenduex trunk]$ svn add hw1
A         hw1
[michael@xorenduex trunk]$ cd hw1

I then edit my homework 1 answers file, provide answers to the homework, and add that file to the repository. Note that I must still commit this new file; I have only told the repository that it exists locally, but have not moved the content to the server.

[michael@xorenduex hw1]$ emacs -nw mlocasto.hw1.txt
[michael@xorenduex hw1]$ svn add mlocasto.hw1.txt 
A         mlocasto.hw1.txt
[michael@xorenduex hw1]$ svn status
A       .
A       mlocasto.hw1.txt
[michael@xorenduex hw1]$ cd ..

I ask svn what the overall status of all files in the repository (from this trunk/ directory) is. It tells me that both hw1 and mlocasto.hw1.txt are scheduled for addition to the repository (but are not yet committed).

[michael@xorenduex trunk]$ svn status
A       hw1
A       hw1/mlocasto.hw1.txt

I pull down any changes (there are none) that may have happened while I was editing mlocasto.hw1.txt.

[michael@xorenduex trunk]$ svn update
At revision 1.

I push my changes to the remote repository, adding a comment with the -m parameter.

[michael@xorenduex trunk]$ svn commit -m "LOCASTO: adding hw1, problem 4 was too hard"
Adding         trunk/hw1
Adding         trunk/hw1/mlocasto.hw1.txt
Transmitting file data .
Committed revision 2.

If I want to, I can ask svn for more complete information on the hw1/ directory:

[michael@xorenduex trunk]$ svn info hw1
Path: hw1
URL: svn+ssh://locasto@ec2-50-19-41-44.compute-1.amazonaws.com/home/locasto/repository/trunk/hw1
Repository Root: svn+ssh://locasto@ec2-50-19-41-44.compute-1.amazonaws.com/home/locasto/repository
Repository UUID: 45d0569f-2942-4645-b7eb-dfbbe1985997
Revision: 2
Node Kind: directory
Schedule: normal
Last Changed Author: locasto
Last Changed Rev: 2
Last Changed Date: 2012-01-17 13:02:40 -0700 (Tue, 17 Jan 2012)
[michael@xorenduex trunk]$