SVN undo delete before commit

If you delete a directory from an SVN working copy, but haven't committed yet, it's not obvious how to get it back. Google even suggests "svn undo delete before commit" as a common query when you type "svn undo d", but the search results are unhelpful.

edit: I'd like a solution that works in subversion 1.4.4


Solution 1:

1) do

svn revert . --recursive

2) parse output for errors like

"Failed to revert 'dir1/dir2' -- try updating instead."

3) call svn up for each of error directories:

svn up dir1/dir2

Solution 2:

svn revert deletedDirectory

Here's the documentation for the svn revert command.


EDIT

If deletedDirectory was deleted using rmdir and not svn rm, you'll need to do

svn update deletedDirectory

instead.

Solution 3:

What worked for me is

svn revert --depth infinity deletedDir

Solution 4:

Do a (recursive) Revert operation from a level above the directory you deleted.

Solution 5:

To make it into a one liner you can try something like:

svn status | cut -d ' ' -f 8 | xargs svn revert