How to undelete from the SVN Repository
Asked Answered
B

8

6

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?

Buckley answered 24/5, 2010 at 22:0 Comment(1)
possible duplicate of What's a simple way to undelete a file in subversion?Seineetmarne
C
8
  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
Calpac answered 24/5, 2010 at 22:6 Comment(2)
This isn't the recommended method. Using copy @REV is as you can track where stuff come from. Just manually copying the files in on the file system trashes the history.Hostetler
If you use "SVN Copy", it will properly record the revision the copy was made from. I just tested this using exactly the above description, and the log in TortoiseSvn now shows that the directory was copied from revision 1 (where it exists).Technician
L
5

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.

Loathe answered 24/5, 2010 at 22:22 Comment(1)
It does appear to preserve the history.Monohydric
H
1

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.

Hostetler answered 24/5, 2010 at 22:5 Comment(0)
M
0
  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.

Metatherian answered 24/5, 2010 at 22:14 Comment(0)
A
0

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

Amboina answered 24/5, 2010 at 22:15 Comment(0)
S
0

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) :)

Seineetmarne answered 24/5, 2010 at 22:41 Comment(0)
A
0

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!

Amperage answered 12/5, 2011 at 8:20 Comment(0)
S
0
  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!

Sidnee answered 26/7, 2023 at 7:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.