Subversion is a centralized version control system developed to address the shortcomings of CVS. The main Subversion documentation can be found here:
Getting Started With Subversion
Most commands have built-in documentation you can access with the --help option:
Checking out a remote repository
Use the svn checkout command to get a working copy of a Subversion repository:
The "URL" is often an
http://... URL, but may also be
svn+ssh://... for access over ssh, or
file://... for access to a repository on the local filesystem.
For a local repository:
For a repository hosted on the CIT Subversion server:
You can elect to checkout only a particular subtree of a repository. For example, if you really like the images in this presentation:
svn add process schedules individual files or directories in your working copy to be added to the repository next time you commit your working copy:
For example, let's say I wanted to package up the hello project for the Fedora project. I'd need to create a package specification, or spec, file and then add it to the repository:
Use svn rename to rename files in the repository:
Use svn delete to remove files from the repository:
Removes the file from your working copy and schedules a remove from the repository (next time you commit).
If you remove the file manually, you will still need to issue svn delete after the fact to mark the item deleted in the repository.
AKA svn rm.
What's changed: status
Use svn status lists the state of files in your working copy:
The svn status command shows you what files in your working copy have been changed (added, deleted, renamed, modified). It will also show you which files are not part of your repository. For example:
This shows that three files have been modified, one has been added, and one is unknown to the version control system.
What's changed: diffs
Use svn diff to display the changes made to your repository:
Without any arguments, display all of the uncommitted changes in your working copy.
Specify TARGET to see just the changes in a particular file or directory.
Use the -r option to look at the changes between specific revisions.
Use svn commit to send changes back to the repository:
Subversion will start an editor allowing you to provide a commit message (you can also provide one with the -m option).
Updating your working copy
Use svn update to update your working copy with changes from the repository:
You can elect to update only a particular subtree of your repository by passing an optional path argument, e.g:
A conflict occurrs when two people make overlapping changes.
Detected when you attempt to update your working copy.
You may discard your changes, discard the repository changes, or attempt to correct things manually.
If you attempt to update your working copy and Subversion detecs a conflict, you will get a warning like this:
Selecting ``mine-conflict`` will discard the repository changes
(keeping your local changes), while selecting ``theirs-conflict`` will
discard your local changes.
The svn log command shows you the history of your repository:
svn log command with no arguments will show you the commit messages for each revision in your repository:
Tagging and branching
Tags and branches are naming conventions. Use
svn copy to create tags or branches. Tags and branches are space efficient because they are copy-on-write operations.
The conventional layout of a Subversion repository looks like this:
You normally work in the trunk directory. To create a tag:
Or to create a branch:
While functionally the same, the convention is that you do not edit things in the tags/ tree, while you may change things in the branches/ tree.
See choosing a repository layout from the Subversion documentation for more information.
Creating a repository
svnadmin create to create a new repository:
REPOS_PATH is a local filesystem path.
If you will be accessing the repository remotely (or offering remote access to collaborators), you will need to decide what sort of remote access to provide. Your options are:
(subversion's native protocol)
(subversion over ssh)
(subversion over webdav)
The Subversion page on choosing a server configuration provides more information about the pros and cons of each of these methods.
You could then access this using the URL
svn: Importing files
svn import imports an entire tree into an existing Subversion repository:
For example, if I wanted to start using Subversion to track changes to the hello project, I might do something like this:
And the output would look something like this:
Note that svn import does not modify your current directory! You would still need to issue an svn checkout to get a working copy of the repository.