Rollback a Subversion commit

Ian Hancock Development

Using the subversion from the command line makes it much easier to accidentally commit changes across a whole project when you only really need to commit certain files that you were working on. If this were to happen you would assume there’d be an easy way to tell subversion “Sorry, I’ve commited that in error please rollback my changes” in a similar way to Microsoft SourceSafe. Unfortunately not.

So whilst looking for a way to do this I came across a solution, which involes a revision merge and commit; basically taking your changes back to a previous revision and then commiting that one.

svn merge -r 73:68 /location/of/your/files/my_file.php

svn commit /location/of/your/files/my_file.php -m "reverted to revision 68."

There was some minor housekeeping needed on the file after the initial merge to remove any conflicts but the process worked, if only this could be done with a single command.