Clay Nichols
Clay Nichols

Reputation: 12139

How to undelete from the SVN Repository

I accidentally deleted a major folder inside of the Tortoise-SVN Repro Browser. The working folder is unaffected.

What is the recommended way to reverse that?
Do I just Revert back to the previous version? Or do I need to do a Checkout to that previous version into a new folder and delete the old folder?

Upvotes: 6

Views: 8388

Answers (8)

Hans Geukens
Hans Geukens

Reputation: 11

  1. in the repo-browser change the focus to the revision that still holds the deleted item/folder
  2. right-click the item/folder and select 'copy-to'
  3. you 'll get the suggestion to copy it to itself but now it will be in the HEAD revision
  4. when looking at the 'show log' be sure to un-select the 'stop at copy' to see the older commit comments

enjoy!

Upvotes: 0

raudi
raudi

Reputation: 1730

for the command line enthusiasts:

  • first find the revision number where your delete happened:

    svn log -v http://svnserver/path/to/folderContainingDeletedFolder
    

say you find that the directory was deleted in revision 999 (btw: you might find it easier to find the revision number with the svn repo browser)

  • copy the folder from revision minus 1

    svn copy http://svnserver/path/to/folderContainingDeletedFolder/deletedFolder@998 http://svnserver/path/to/folderContainingDeletedFolder/deletedFolder -m "undeleted folder"
    

voilà you're done!

Upvotes: 0

gbjbaanb
gbjbaanb

Reputation: 52659

Have you tried the TortoiseSVN docs?

This is described as Rollback revisions.

What happens is that you rollback the deletion, so the previous version (the one before you did the delete) becomes the new HEAD revision. The deletion will still appear in the log, but it also describes how you can save your embarrassment (though that's more complicated) :)

Upvotes: 0

Joshua Flanagan
Joshua Flanagan

Reputation: 8557

Since you mentioned you are using TortoiseSVN:

Do a TortoiseSVN | Show Log on the working directory. Right click on the checkin where you deleted the folder. Choose Revert changes from this revision.

That will re-create the missing files in your working folder. You can then revert any OTHER changes that were in that revision that you actually want to keep. Once you have your working folder in the state you want it, commit.

I am not sure if this method preserves the history.

Upvotes: 5

There are other questions similiar to yours here at Stackoverflow. Maybe you could find something useful from the answers there.

Upvotes: 0

Andrew
Andrew

Reputation: 7516

  1. Check out the latest version of the repo to a new directory.
  2. Use Tortoise to merge to the version before your deletion.
  3. Check in the results of the merge.

See the Subversion book for more info.

Upvotes: 0

Nick DeVore
Nick DeVore

Reputation: 10166

  1. Update your working copy to the head version
  2. Check out the prior version to a new folder
  3. SVN Copy the deleted folder from the priorVersionFolder to the headVersionFolder
  4. Add in the headVersionFolder
  5. SVN Commit the headVersionFolder

Upvotes: 8

Dan McGrath
Dan McGrath

Reputation: 42008

You can do a copy from the revision just prior to the deletion to add it back into the repo.

Their isn't a real 'undelete' option in svn.

Upvotes: 1

Related Questions