Take the 2-minute tour ×

In revision 1 a folder existed. In revision 2 the folder was accidently deleted and the change committed.

We wish to roll back such that the folder is present, and retain its history.

In the TortoiseSVN docs it indicates 'how' in the section titled "Getting a deleted file or folder back".

To quote:

Getting a deleted file or folder back

If you have deleted a file or a folder and already committed that delete operation to the repository, then a normal TortoiseSVN -> Revert can't bring it back anymore. But the file or folder is not lost at all. If you know the revision the file or folder got deleted (if you don't, use the log dialog to find out) open the repository browser and switch to that revision. Then select the file or folder you deleted, right-click and select [Context Menu] -> [Copy to...] as the target for that copy operation select the path to your working copy.

A switch retrieves the file into my working copy as one would expect, however there is no "Copy to" option on the context menu when I right click this working copy. If I open the repos browser, there is a copy to option, but it seems this simply takes a copy of the file.

The solution I feel is to do a Branch/Tag, but if I try this from a prior revision to the same path in the repository SVN throws error that the path already exists.

Therefore, how do I recover a folder/file in TortoiseSVN whilst also retaining all history.

TortoiseSVN v1.6.8, Build 19260 - 32 Bit , Subversion 1.6.11,

share|improve this question
add comment

4 Answers

up vote 6 down vote accepted

Do a "reverse merge":

  1. Ensure that your working copy is updated to HEAD and completely clean (not strictly necessary, but always a good idea before trying to merge)
  2. Right click on the folder and select TortoiseSVN > Merge...
  3. Select "Merge a range of revisions" and hit "Next"
  4. The URL to merge from is the repo path for your current directory (ie. the one containing the deleted file)
  5. The revision range to merge is the revision in which you deleted the file (show log might help here)
  6. Be sure to select "Reverse merge"
  7. Hit "Next"
  8. All the default merge options should be sufficient, so hit "Merge"

The file should now be added and still retain all of its previous history.


This "rolls back" the revision containing the deletion, but adds the merge information to the directory properties. SVN can track the original file through this metadata. On the command line you would to do a backwards merge of the revision in which you deleted it:

svn merge -c -<revision-number> path/containing/file

Note the hyphen before the rev number (ie. a "negative" revision nunber).

share|improve this answer
Thanks, this worked. I expect behind the scenes it might work like the copyto mentioned by khmarbaise, but haven't verified that approach would retain history. –  Topdown May 19 '10 at 6:12
If I get time to check it out later then I'll post the results here. –  detly May 19 '10 at 6:17
add comment

"Copy to" in the repository browser is correct. I think you missed the fact, that this is a svn copy that retains the history information. Exactly what you asked for.

share|improve this answer
add comment

What you describe with "Copy to" is only in the Repo-Browser is correct. That's exactly the way you should recover your file. On the other hand, what's wrong with copying ?

share|improve this answer
add comment

I think you can use the "Branch/Tag..." option in the context menu to do this, only specifying a particular revision as the source and the trunk as the destination.

AFAIK, it's the equivalent of the svn copy command line.

You could also use svn copy from the command line as well...

share|improve this answer
Yes, I thought this of Branch/Tag also, however it complains because the destination already exists. Must be some internal TortoiseSVN check? I'll try the copy approach or backwards merge suggested by detly if no further Tortoise suggestions –  Topdown May 19 '10 at 5:55
The destination needs to be in the repo, probably something like http://someserver/svn/foo/trunk/MissingDir, rather than the working copy. –  msandiford May 19 '10 at 7:06
add comment

Your Answer


