[svn] 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

This question is related to svn directory undo delete-directory

The answer is


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


You could remove the folder and update the parent directory before committing:

rm -r some_dir

svn update some_dir_parent


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

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

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

What worked for me is

svn revert --depth infinity deletedDir

The simplest solution I could find was to delete the parent directory from the working copy (with rm -rf, not svn delete), and then run svn update in the grandparent. Eg, if you deleted a/b/c, rm -rf a/b, cd a, svn up. That brings everything back. Of course, this is only a good solution if you have no other uncommitted changes in the parent directory that you want to keep.

Hopefully this page will be at the top of the results next time I google this question. It would be even better if someone suggested a cleaner method, of course.


Examples related to svn

Error "can't use subversion command line client : svn" when opening android project checked out from svn How to view changes made to files on a certain revision in Subversion Intellij idea subversion checkout error: `Cannot run program "svn"` How change default SVN username and password to commit changes? How to rename a file using svn? Connect Android Studio with SVN svn: E155004: ..(path of resource).. is already locked SVN Commit failed, access forbidden How to add an existing folder with files to SVN? Update OpenSSL on OS X with Homebrew

Examples related to directory

Moving all files from one directory to another using Python What is the reason for the error message "System cannot find the path specified"? Get folder name of the file in Python How to rename a directory/folder on GitHub website? Change directory in Node.js command prompt Get the directory from a file path in java (android) python: get directory two levels up How to add 'libs' folder in Android Studio? How to create a directory using Ansible Troubleshooting misplaced .git directory (nothing to commit)

Examples related to undo

How to recover the deleted files using "rm -R" command in linux server? What is difference between 'git reset --hard HEAD~1' and 'git reset --soft HEAD~1'? Can I delete a git commit but keep the changes? git undo all uncommitted or unsaved changes How to go back (ctrl+z) in vi/vim How do I "un-revert" a reverted Git commit? How to undo a git pull? How to uncommit my last commit in Git Undo a Git merge that hasn't been pushed yet SVN undo delete before commit

Examples related to delete-directory

Ansible: How to delete files and folders inside a directory? How to delete a folder with files using Java How to delete directory content in Java? How to delete a whole folder and content? How do I recursively delete a directory and its entire contents (files + sub dirs) in PHP? SVN undo delete before commit How to recursively delete an entire directory with PowerShell 2.0? How to fix "containing working copy admin area is missing" in SVN? In Unix, how do you remove everything in the current directory and below it? Delete directories recursively in Java