Subversion: Restore deleted files

If you accidentally delete a file and then commit the change, you can retrieve the file along with the rest of the history by using svn copy to copy it into your working directory. svn copy -r revision-number your-full-repository-path-to-the-file file

UPDATE: pgier suggested svn copy http://svn/url/to/file@revision-number file

Common Use-Cases for Merging

2 Pingbacks/Trackbacks

  • Doug

    Thank you for your posting. Can you give an example of the full repository path? Is this something that exists in all installations of OS 10.5, or does it have to be setup separately?

    Also, sorry for asking, but what is a “revision-number” and how do I find it?

    Thanks.

  • Paulie

    I was trying to restore a deleted file through Subclipse on Eclipse. I don’t know how to submit a console command to Subclipse, and I couldn’t use “Restore from local history,” since it was deleted by someone else. The only way I found to do it was to go through the parent folder’s history and find what revision deleted the file. I then went to the SVN Repository and checked out the parent folder with the revision just before the delete.

  • http://markphip.blogspot.com/ Mark Phippard

    Paulie,

    This blog post explains how to do it in Subclipse:

    http://markphip.blogspot.com/2007/01/how-to-undo-commit-in-subversion.html

    Mark

  • http://grindinggier.blogspot.com pgier

    For some reason, the above syntax for specifying the revision didn’t work for me, and I kept getting “path not found errors”. It’s probably because of some strange setup in our svn server.

    Instead I had to specify the revision number in the svn url like this:

    svn copy http://svn.mycomp.org/repos/project/MyFile.java@99 MyFile.java

  • vel

    I am using subversion last 6 month.i have 6 month data in svn server.my data’s and configuration foldes also deleted,i am copied subversion repository folder structure full path daily basis.so i replace the subversion repository folder structure previous date backup.now it’s working fine.

    1.But if i don’t have backup of SubversionRepository folder structure, then how to retrive the data?

    2.if i have backup of SubversionRepository folder structure, when server is down,then how to configure/restore to another system on old repository folder structure?

    Please help me.

    Thanks,Vel

  • http://sachachua.com Sacha Chua

    Err, I’m not sure. Good luck finding out!

  • vel

    1.Q: if i don’t have backup of SubversionRepository folder structure, then how to retrive the data?

    Ans:Try to use the recovery software and get the data after follow the second point.

    2.Q:if we have backup of SubversionRepository folder structure, when server is down,then how to configure/restore to another system on old repository folder structure?

    Ans:If we have tape drive backup of SubversionRepository folder structure we can restore the data to another one system.i followed the command and successfully restored

    svnadmin dump C:/SubversionRepository > D:/repository.dumpfile

    svnadmin load G:/SubversionRepository < D:/repository.dumpfile

    C:/SubversionRepository —– Old Repository path

    D:/repository.dumpfile —— Backup path

    G:/SubversionRepository —— New Repository path

  • http://sachachua.com Sacha Chua

    Thanks for sharing! =)

  • Pingback: Restoring deleted files from an SVN repository « simonwheatley.co.uk

  • http://www.cybermato.com Chris MacGregor

    Thanks, pgier – that syntax (copied below) worked for me, too:

    svn copy http://svn.mycomp.org/repos/project/MyFile.java@99 MyFile.java

    (The -r syntax didn’t work, nor did specifying the file without the full path to the repo.)

    I’m using svn 1.5.6 – I’m guessing that the -r syntax works in some other svn version (probably older).

  • http://sachachua.com Sacha Chua

    Noted and updated in the blog post. Thanks! =)

  • Chaya

    I have deleted the file in SVN in user local system, but it has got deleted in the Main repository also. How can i recover the same.

    Please help its a critical data.

    Regards,
    Chaya

  • http://sachachua.com Sacha Chua

    How did it get deleted? Try the svn copy command above.

  • Shiv

    Do you happen to know if there’s a difference between doing it the way you proposed versus using TortoiseSVN right-click feature as mentioned here?

    http://tortoisesvn.net/most-forgotten-feature

    I tried the TSVN way, and it seemed to work for me. That is, all of the log history is still retained.

  • http://sachachua.com Sacha Chua

    Oh, I was on Linux, so I wasn’t using TortoiseSVN. Glad that works for you! =)

  • vel

    Hi, my svn repository is in live.but Drive size 200GB is going to full.so i am added 500GB Hard disk in same system.How to move my svn repository one drive to another drive (ex:E drive to G drive).please help me,Thanks in advance,Vel

  • Pingback: SVN: restore deleted files | physiophile