2008-01-21

Reverting to a Specific Revision with SVN

Suppose you've edited a file, checked it into SVN, then realized it's completely broken. SVN won't let you revert to a specific revision directly, so you can do something like: svn up -rX; mv file file.old; svn up; mv file.old file; svn ci file; where X is the last correct revision of the file in question.

There's an easier way to do it, though: svn diff -rX file | patch -R file; svn ci file

This gets a diff between your (incorrect) version and the last correct version, then applies the patch (in reverse) to the file so you get the old version back.

Just a handy trick.