SVN: Restore Deleted Folder from a Revision

Imagine a situation: you accidentally "svn removed" an entire directory tree from SVN. If the tree contained uncommitted code you can restore it from the backup, but you also need to restore things that were in the SVN. You can approach it multiple ways, but arguably the cleanest way is to simply revert to the revision before the deletion.

How do you do that in Subversion? The answer to this is quite short, but not necessarily obvious, so following is the list of example commands:

svn co -N SVN_PARENT_URL  . 
svn copy SVN_URL@REV FOLDERNAME
(Add-in or modify here any files that were not committed, before deletion)
svn commit -m "restoring" FOLDERNAME

example:

svn co -N https://svn.ex.com/repo/project/parentfolder@7537 . 
svn copy https://svn.ex.com/repo/project/parentfolder/deletedfoldername@7537 deletedfoldername
(Add-in or modify here any files that were not committed, before deletion)
svn commit -m "restoring" deletedfoldername

Deleted Folder

Thanks - this has been helpful. Just hope it does not happen to me.

Thanks

I spent half an hour of Googling "path not found" errors since my svn copy -rxxx deleteddir branchespath was not working before I found your post. Works perfectly.

Restore Deleted Folder from a Revision

That was a bad thing ... how did you feel after you deleted them?Busted?

Man, this just saved me

Man, this just saved me hours of fiddling with Tortoise. Not quite what I needed, but almost.

Thanks

Great simple explanation that helped me restore a directory some doofus ;) removed. But then, who needs the tags directory anyway...

Just happened to me :(.

Just happened to me :(. Your're a lifesaver