SVN Tip: Overwrite Corrupted Revision

July 14, 2008


Yet again I was saved from a catastrophic failure by using SVN. If you are not using SVN or some sort of version control I highly recommend using SVN as it will save you from losing your work time and time again.


SVN Reverse Merge


The common way to roll back a change is the reverse merge. You are taking the old revision and merging it into your working directory.For instance, here we could merge revision 117 into our working directory with this command:



svn merge -c 117 ./

In the case of a corrupt check in, this may not be possible.SVN was essentially “stuck” for me at a revision because of some errors that occurred (don’t ask me how I got to this point, lol). So I had to come up with another solution…

“Side Steping” Latest Revisions

SVN was corrupted at revision 118+ and so I could not __ get anything working if I svn updated to the latest.

So, I came up with this, “side steping” method where you can roll back to an old revision without having to svn update to the latest revision. To pull it off, we first need to delete the latest working copy, then we resurrect the old revision.

1. Delete the current folder in SVN that contains the corrupted file folder.

svn delete file:///svnroot/domain.com —message ‘deleting corrupt revision’

2. Resurrect the stable revision (in this case #117) with SVN copy . The -r flag allows us to enter the revision number that we want to resurrect.

svn copy -r 117 file:///svnroot/domain.com file:///svnroot/domain.com —message ‘resurrecting the old revision’

3. Check out the latest from SVN and you are back on the road!

svn co file:///svnroot/domain.com

If you are not sure what revision to roll back to, you can always use svn log to review your previous commits to find the stable revision number.

This method sure has saved me from what could have been a world of coding pain.

9 comments

#1. Felix Geisendörfer on July 15, 2008

Use git : ).

#2. Marc Grabanski on July 15, 2008

Thanks Felix, I have heard of git before and will try it when I get the chance.

#3. Sebastian on June 19, 2009

So did Git work for you?

#4. Mike Kale on August 25, 2009

Gosh, you git folks are persistent!

#5. Marc Grabanski on August 25, 2009

The interesting part of this is that I did end up (mostly) switching to git. I was having problems with a few SVN repos and needed a more stable alternative. Turns out git is actually really good stuff.

#6. Anonymous on October 09, 2009

Thank you very much for this tip. It was invaluable.

#7. Mike on February 12, 2010

BZR > GIT

#8. Chris on July 22, 2010

screw git

#9. Karl on January 22, 2011

Thanks. This help me to get rid of wronly moved folders (mv instead of svn move).

Leave a comment

Comment in textile images by gravatar