Categories
Posts

Revert to a Previous Version in Subversion

Most of the time when I’m working with code that is checked out from Subversion it’s moving forward, version after version. There are times though where I need to revert back to a previous version (one reason you should have your code versioned in the first place). Subversion can do this, but it isn’t via the revert command, instead it’s done with merge.

Most of the time this means I can revert my working copy to rev 12345 with this command:

svn merge -r HEAD:12345 .

The merge command requires a directory parameter, the dot just means the current directory. This only reverts your working copy though, so don’t forget to commit after merge.

Reverting back to a previous version is one of those things that I do infrequently enough that I end up searching for how to do it each time. Perhaps writing about it will help me remember this a bit better. If nothing else I know where to look for a quick example now.