There are only two things you need to be a great programmer: curiosity and kindness. Everything else you can learn over time. Everything.

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
comments powered by Disqus