SVN Cheat Sheet

Subversion is an OpenSource revision control system that is extremely useful for software developers, writers, or anyone who needs to collaboratively work on large projects.  Despite its power and usefulness, though, Subversion can be daunting to use and set-up for the first time.  Here, you will articles, links and other aids which can simplify the process.  If you are completely new to Subversion, check out the article “Getting Started with Subversion,” which will cue you into why revision control is cool,why it may be useful for you, and how to get started.  After that, you might want to check out “A Personal Subversion Server Based on Ubuntu Linux,” which will walk you through the creation of a personal home server using an old, cast off computer.

Articles

Getting Started with Subversion

  • Part 1: The Basics.  A brief article that describes how to use Subversion for the first time.  Everything that a budding SVN user needs to know including how to install,  import a project, check-out files and later commit the modified versions.
  • Part 2: Advanced Stuff.  A deeper look at Subversion.  The article includes how to revert to older copies of a file, resolve errors, and merge two working copies with a conflict.

A Personal Subversion Server Based on Ubuntu Linux

A Windows Based Subversion Server (via Lifehacker)
The Definitive Guide to Using Subversion

Software

While the basic Subversion utility is command line only, there are a number of programs that can make working with Subversion substantially easier and more pleasant.  Here are some of my favorites:

  • Tortoise SVN.  A shell utility for Windows that makes working with repositories as easy as working with local files.  Includes a fantastic repository browser.
  • Rapid SVN.  Cross platform front-end to Subversion.  It works on Linux, Mac, Windows and other BSD variants.
  • SCPlugin.  Integrates Subversion into the Mac OS X Finder.  Similar to Tortoise SVN for Windows, but without the handy repository browser.

Command Line Help

While you can get an extremely long way by use of GUI tools, sometimes you will encounter a problem that requires time spent at the command line.  This doesn’t necessarily have to be painful.  Beside, occasionally working at the command line is good for you, it makes you extend and grow as a person.  (This guide is modified from a similar list of hints.)

Creating a repository. This command should be run on the computer where the repository will be hosted.  Administrator (root) access is typically required.

svnadmin create /path/to/repos

Checking out a repository or folder. To check out a file or folder from a repository over http://, use:

svn co http://hostname/path/to/repos

Alternatively, you can check out a repository over svn and ssh:

svn co svn+ssh://hostname/path/to/repos

Or if checking out a copy from the local machine:

svn co file:///Path/To/Repository/DirName

Adding, deleting, moving files. Because subversion keeps track of all changes to a given file, you need to tell it when you add, delete, or move a given file.  When done correctly, Subversion will move the file history with it.  When not done correctly, you will make a mess.  All of these commands are run inside the project directory on the local machine (not inside the repository).  To add a directory full of files, type:

svn add filename/directory-name

To remove a directory, type:

svn rm filename/directory-name

When all of the changes are finished, they need to be committed (including a helpful message so that you can remember what changes were made):

svn commit –m “Message Goes Here”

Checking the status of files. To see the status of a directory against the repository, svn status and svn diff are invaluable.

svn status will return a list of files that have changed, moved, or that the computer thinks is worth your attention.  The more common flag codes are: M = Changed, ? = Not part of the repository, A = Scheduled to be added to the repository, D = Scheduled to be deleted from the repository, C = Conflict.

Getting information about a repository. The svn info command will return information about a particular project directory.

svn ls will list the contents of a repository, similar to the ls command in Unix operating systems.

Comments

No Responses to “SVN Cheat Sheet”

Care to comment?