This tutorial will cover the absolute basics of using the Apache Subversion command line tool. It is aimed at people who are using svn for the first time or who have used guis for svn before but are considering using the command line tool from now on.

Why use apache subversion command line tool

My memory is not too great, so I try to avoid using command line tools (it is quite annoying having to look up every other command in the help pages). But subversion is easy to use as it only has a couple commands. Here, I will describe the onces you will need most often (and maybe even the only once you will ever really need). The advantages of the command line are flexibility (you definitely can use all commands subversion offers, not all guis provide these), easy usage, and certainty that no extra bugs are added by a gui.

Using apache subversion command line

svn help
is really useful here. It lists all commands and you may get descriptions of each command by typing
svn help commandname

Download a complete new repository into subversion

Use this command if you want to use a repository that you have never used before:

svn checkout --username yourusername

Download changes in existing repository to local working copy

This will download all changes that others have committed to the remote repository to your local copy of it:

svn update

Add file to remote subversion repository

the first line adds the locally existing file filename under version control, the second line sends these changes to the remote subversion repository.

svn add filename
svn commit

Add directories (recursive) to remote subversion repository

the first line adds all newly created files in the directory under version control, the second line sends these changes to the remote subversion repository.

svn add --depth=infinity *
svn commit

Delete files or directories from remote subversion repository

the first line deletes the given file or directory (recursively) in local copy, the second one commits these changes to repository (meaning it will delete it on the server).

svn delete fileOrDirectoryName
svn commit

Notes on committing

When doing a commit in svn, it is a good idea to add a message, so other people know what exactly you did.
svn commit -m "added xyz and fixed abc"

Also, and I cannot stress this enough: do NOT commit broken code. People seem to do it all the time, and I have no idea why. It is annoying as hell.

General tips/ problem solving

  • Login per command line not working: specify username with –username yourName
  • if you are still having problems using your correct login credentials this command it might help to delete your keyring:
    rm ~/.gnome2/keyrings/login.keyring

Tips on not breaking svn

  • Do not move or change the .svn directories (well, except you really know what you are doing maybe, but then you would probably not be reading my text).
  • Try changing the directory structure with svn build in commands (like delete or move) instead of doing it with a file manager
  • Always do an update before making changes and a commit afterwards
  • Do not use RapidSVN (more below)
  • if you are working on a very large team or are not communicating with your few team members very well learn about and use the lock command to prevent files from being changed by multiple persons

Alternatives to subversion command line: SVN Guis

RapidSVN: Quite honestly, it sucks. It is at Version 0.12 and not being developed anymore (i think), so this really is no surprise. It broke more for me than it helped.

Netbeans: works great (did not brake anything for me up to now); easy to use; color codes files right in IDE, which is quite useful. If you develop your project in Netbeans anyways, I suggest you use it.

That is already it so far for the tutorial about the svn command line tool. I think I covert all the basics (turns out it is less than I expected to write).