I use subversion for source control. There may well be better options out there (git anyone?) but it works fine for me 99% of the time. Someone I know was recently wondering how to retrieve a directory he’d deleted from his subversion repository, so thought I’d post this.
Since there is not a general “undo” in subversion, you have to copy the directory (or files, which this also applies to) from the revision before the commit which removed the directory or file to the “head”. This allows you to retain the original history. You can actually do this all in one step, however doing it as a multi-stop process using a local working copy allows you to review and validate that you’re doing the right thing in between steps.
The basic process is that you first copy the revision with your deleted directory or file down to a local working copy, then copy the directory or file up to the original location in the remote repository.
In case you don’t have a working copy, just check out the parent directory (the head revision) as a local working copy. For this example, parent is the original parent directory of the removed object, myObject is the object that was removed, and “4906” (arbitrary revision number) was the svn revision before the object was removed.
Checkout a local working copy if you don’t have one.
svn checkout http://myRepostoryServer/project/web/src/parent
Then copy from the deleted object from the remove repository / revision to the local working copy.
svn copy http://myRepostoryServer/project/web/src/parent/myObject@4906
Finally after you’ve checked out the locally recovered object, check it back in to the remote repository.
svn copy myObject http://myRepostoryServer/project/web/src/parent -m "Restore myObject to previous state"