This post originated from an RSS feed registered with Ruby Buzz
by Jay Fields.
Original Post: Subversion: Rolling back revisions
Feed Title: Jay Fields Thoughts
Feed URL: http://blog.jayfields.com/rss.xml
Feed Description: Thoughts on Software Development
Earlier this week someone mistakenly checked in some experimental code and wanted to back that code out. If you've never needed to do this, you might think that Subversion gives you a command to make this happen easily, it doesn't. In fact, I've found that to be a fairly common misconception.
There may be easier ways, but the following steps are the ones I take to roll back a specific revision.
Find the revision that you wish to back out. This can be done with various tools, but 'svn log --limit 10' will probably do the trick. Once you have the offending revision you are ready to get started. (Revision X in the example is the revision that needs to be rolled back and revision Y is the revision that came immediately before X [i.e. X-1])
svn diff -rX:Y > a.patch
patch -p0 < a.patch
svn commit
note: while it's possible to give patch parameters and do this pretty much anywhere in the tree, I'd stick to doing this in the root folder of your project, for simplicity.
Again, there is probably an easier way to do this (which is part of my motivation for writing this entry), and obviously this solution depends on having 'patch' available.