Resetting your SVN repository to a previous revision
NOTE: See the improved version of this shell script here: http://andrewbuntine.com/articles/2008/11/26/an-improved-shell-script-for-svn-resetting
For the majority of the year, I have been using Git as my preferred version control system. Recently, however, I have been using Subversion on some older projects at work.
One thing I have noticed is that the "revert" command seems to be oddly named. It's more of a svn-merge-and-undo. Maybe it's just me?
In either case, I wrote a little shell script that will act more like the Git-equivelant by allowing you to forcfully revert back to any previous revision of your project. It looks like this:
if [ $# = 3 ] then currdir=`pwd` cd $2 svn update svn merge -rHEAD:$1 $3 svn commit -m "Reverted back to r$1" cd $currdir exit 0 else echo "svnreset needs three arguments!" exit 1 fi
Save it as "svnreset" and call it like this (the period is intentional):
$ svnreset 200 . svn://server/project/trunk
That will reset your project to r200, provided you are currently in the repositories root directory. Note also, the changes will be committed as a new revision, so if you make a mistake, just reset the reset!
I suggest that you create a symlink to /usr/bin so you can just call it straight from the terminal whenever you need it.