Subversion Commands (Cheatsheet) | My Outsourced Brain

Subversion Commands (Cheatsheet)

About two weeks ago my hard disk failed. I got a new one the following day from our vendor and had my system configured very fast (see other post). However, I had been lazy in using subversion and I lost two posters I had created. I was very angry with myself. As a reminder to myself this post is about subversion.

In case, you didn't know, subversion is a program that allows you to store different versions of files, so you can revert edits, restore deleted files, and much more. This video gives a basic introduction.



In this post I will list the most important subversion commands, from creating a repository on a remote server to committing and updating locally on the machine you are working on. In a later post I am going to explain how to automate this incremental backup.

We will first need to create a repository on the server and then tell subversion that a directory on a local machine we are working on corresponds to that repository. After that we can start committing local changes and update our local files.

On your server you create a subversion project:
> svnadmin create path

Locally, you can start working, starting by checking out the project from the server:
> svn co svn+ssh://url/path local_directory

You need to give the full (absolute) path to the directory (otherwise you'll get "no repository found").

If you have your repository on the same computer use instead:
> svn co path local_directory
Here you can give a relative directory.

or

> svn co file:///home/yourname/svnrep/ newprojectpath

Now we can start working by creating files and editing them. We add the files to the version control:
> svn add filename

Finishing work (or always after having made some major changes), we commit the changes to the repository:
> svn commit -m "changelog"

Next time you start working, if you made changes from another computer, do an update:
> svn update

or (if you are not in the directory)

> svn update local_directory

We can always check out all subversion commands by typing svn help and get help on a command by typing svn update command.

svn status always gives you summary information about whether and how your data is changed:

A Added
D Deleted
U Updated
C Conflict
G Merged
E Existed

It is often useful to be remembered whether you need to add some more files to the version control:
> svn status | grep ^?

I find symbolic links very useful. Subversion recognizes and can administrate symbolic links, however if you had a file which you want to change for a symbolic link, you need to set the svn:special property of the file (otherwise you get the error svn: Entry 'yourfile' has unexpectedly changed special status):
> svn propset svn:special on filename

In the contrary case, if you change symbolic links to files delete the svn:special property:
> svn propdel svn:special filename


That's the basics and you can do with knowing these commands, but of course there's much more functionality, which you kind learn about from the official manuals.

In another post I explain how to synchronize you repository automatically and in yet another I compare some commercial providers of remote backup servers.

Enjoy. Please leave a comment below for questions and suggestions.



If you use information from this article on your site, then please provide a backlink to it. You can use the following markup:
<a href="http://www.myoutsourcedbrain.com/2008/08/subversion-commands.html">Subversion Commands (Cheatsheet)</a>

0 comments:

What do you think?
Post a Comment