Quick SVN Tutorial


Importing an existing project

Let's suppose you have an existing project with a bunch of files in /path/to/project/. For example :

cd /path/to/project
tree -a
.
|-- bin
|   `-- main
|-- doc
|   `-- index.html
`-- src
    |-- Makefile
    `-- main.cpp

3 directories, 4 files

To place it under version control with svn (i.e. to import the project), the first thing is to clean all files that are not meant to be version-controlled such as compiled code, binary executables, etc.

rm -f bin/main

Then we do the import with the following command :

svn import /path/to/project/ file:///user/cse435/web/Projects/F07/group* -m 'Initial import'
To see the contents of the SVN repository, type :
svn ls file:///user/cse435/web/Projects/F07/group*

Checking out a project

To checkout the project from the repository, type :

cd /path/to/project
cd ..
rm -rf project
svn checkout file:///home/user/svn/project

Remember that the third command removes your original files!

You may want to choose to check out the files in another location.


Working with the repository


To add files that we indeed want to version control :

cd /path/to/project/trunk/
svn add src/class.h src/class.cpp

When you are done with modifications, you may decide to commit these changes :

svn commit -m 'Use a class to print hello world'
When you want to start working, it is a good idea to update your files, since other people may have uploaded new versions of old files:
svn update

Remote repository

If you would like to access a remote repository, you can replace “file://” by “svn+ssh://”. For example:

svn+ssh://borzoo@www.cse.msu.edu/~cse435/Projects/F07/group*