Subversion is a version control system meant to improve upon CVS, not that that’s particularly difficult. It’s the one I’m currently using for my personal projects - I tried Git and didn’t like it very much, and my favorite VCS, Perforce, is unfortunately not free. This is just an introduction to basic SVN commands.
svn co - SVN checkout, or co, is what you use to first check out a repository. To use it, just do svn co LOCATION in the directory you want the repos to be checked out in. For example, to checkout a new copy of my .emacs.d directory, you can just do ’svn co http://www.nflath.com/svn/.emacs.d’. You can use this to specify which revision you want to check out, as well.
svn add - To add a file to a repository, just do ’svn add filename’. This lets svn know that it should start tracking changes to this file.
svn mv - This will move a file in your repository. You can just do a ’svn rm’ and ’svn add’ after using shell commands to copy a file, but if you use this command you can keep history of the file before you renamed it, which you can’t if you do it by adding and removing files.
svn cp - This acts just as ‘cp’ does in a shell, but also moves it in the SVN repository tracking. If you need to copy a file that is already in the repository and add it to the repos, use this instead of ‘cp’.
svn rm - This acts just as ‘rm’ does in a shell, but also moves it in the SVN repository tracking. If you need to remove a file in the repository, use this instead of ‘rm’.
svn cl - This command creates a subversion changelist. While these aren’t as good as perforce changelists, but they are still quite useful if you only want to check in a subset of what you are working on. A changeless is a subset of your modified files that you can check in as a group, without checking in anything else. This is what I use when I have distinct sets of changes that I have been working on simultaneously and want to check in with different commits. With svn cl, you can also remove files from the changelist.
svn diff - Svn diff allows you to either diff the current file you have against a version in the repository, or two different revisions of a file. Used when you want to see what you or someone else changed in a file.
svn ci - This is what you use when you are finished editing and want to make a checkin. This will open up an editor with the files you are about to check in, and prompt for a log message. svn ci –cl CLNAME will perform a checkin on the files in CLNAME. Unfortunately, unlike in perforce, deleting files from the list of files to check in doesn’t remove them from the checkin itself; I’ve been bitten by this quite a bit.
svn revert - This command is the standard version-control revert command. This will undo any changes to the specified file since the last commit.
svn up - This command will update the repository you have to sync with the server copy, retrieving updates made in another location.
There are of course many more SVN commands, but these are the ones I use most frequently.
Tags: svn
I’m surprised you haven’t mentioned ’svn update’, or ’svn up’. It’s the most essential command to keep your working copy in sync with the repository, after you have checked out your project.
Sergio: Updated! I can’t believe I missed putting that in - I suppose that a lot of my SVN usage is just for personal projects so that I don’t end up losing everything if my hard drive dies, which doesn’t require much syncing.