How do I return to an older version of our code in Subversion?

Chen Kinnrot picture Chen Kinnrot · May 2, 2009 · Viewed 661.4k times · Source

I'm working on a project with a friend and I want to return to an older version of our code and set it to be the current. How do I do it?

I'm using "anksvn" on vs08.

I have the version that I want on my PC, but the commit is failing; The message that I get is "commit is failed, file or directory is out of date."

I also have the subversion client on my PC.

Answer

Jon Skeet picture Jon Skeet · May 2, 2009

Basically you need to "merge backwards" - apply a diff between the current and previous version to the current version (so you end up with a working copy looking like the old version) and then commit again. So for example to go from revision 150 (current) back to revision 140:

svn update
svn merge -r 150:140 .
svn commit -m "Rolled back to r140"

The Subversion Red Book has a good section about this.