开发者

How to undelete from the SVN Repository

开发者 https://www.devze.com 2022-12-31 17:19 出处:网络
I accidentally deleted a major folder inside of the Tortoise-SVN Repro Browser. The working folder is unaffected.

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开发者_JAVA技巧 delete the old folder?


  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


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.


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.


  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.


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

  • How to "undelete" a deleted folder in Subversion / TortoiseSVN?
  • What's a simple way to undelete a file in subversion?


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


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号