Subversion Notes
Introduction
Subversion is a version control system. It manages files and directories over
time in a central repository. The repository remembers every change ever made
to your files and directories. This allows you to recover older versions of
your data, or examine the history of how your data changed. Subversion allows
you to access and change a repository over the network, facilitating
collaboration.
[Paraphrased from Version Control with Subversion]
How to use subversion
- Create a repository for your project.
The repository stores the history of changes you make to your files.
- Add or edit files.
After synchronizing with the new repository you can add and edit files in your project as normal.
- Save your changes to the repository.
This records the modifications you made to your project.
- Go to step 2.
Create a repository for your project
- Create a directory to store your repositories. We recommend you create one repository for each project.
mkdir ~/repositories
- Create a new repository for your project. We will use pa0 as the example project.
svnadmin create ~/repositories/pa0
Retrieving files from the new repository
- Initially retrieving files from the repository is called checking out. You only do this once per project.
svn checkout file://$HOME/repositories/pa0
- This will create a directory called pa0 in your home directory. Project files should be created and edited in this directory.
cd ~/pa0
Add or edit files
- To mark new files to be added to the repository, use the svn add command.
- For example, for the file, pa0.h, type:
svn add pa0.h
- Edit files as normal.
Save your changes to the repository
- Saving your changes to a repository is called committing.
- Any files you files that your marked for add (using svn add) will be added to the repository. Any files you modified will be update in the repository.
- For each change you make, you must provide a brief description of the change.
- For example, after adding pa0.h, to commit your changes with the description 'adding main header file', type:
svn commit -m 'adding main header file'
Re-synchronize with the repository
- Re-synchronizing with the repository is called updating.
- While you only checkout once per project, you may update many times.
- To update your project, type:
svn update
Going back to your last save point
- Going back to your last save point is called reverting. Reverting destroys any changes that have not been committed.
- To revert a file, for example pa0.h type:
svn revert pa0.h
Looking back at previous revisions
- Each time you commit, the state of your project is saved under a revision number.
- To determine the revision number that you want to look at, you can view your previous commit descriptions with svn log.
svn log
------------------------------------------------------------------------
r2 | username | 2007-12-19 03:53:24 -0800 (Wed, 19 Dec 2007) | 1 lines
Made "bad" changes
------------------------------------------------------------------------
r1 | username | 2007-12-19 02:51:37 -0800 (Wed, 19 Dec 2007) | 1 lines
adding main header file
------------------------------------------------------------------------
- To synchronize to revision 1 (r1), type:
svn update -r 1
Working with others
- There are many different ways to set up a repository that can be
shared. If everyone can access the repository location directly, the repository can be checked out by each individual using URL schemes file:// or svn+ssh://.
- For information on checking out a repository remotely using svn+ssh://, see:
Chapter 6, Section 3.4 of Version Control with Subversion.
- When working on a project with others, each person makes changes
independently in their own local copy. To synchronize work, each
programmer must periodically commit changes and update to receive
changes from others.
- Updating can be more complicated in this case due to conflicting changes. See
Chapter 3, Section 5.1 of Version Control with Subversion
for a complete description.
Additional Information
Written by David Lindquist and Michael Kelly.
Thanks to Rick Ord and Nitay Joffe.
Sat Dec 22 20:08:58 PST 2007