4757 comments
2071 subscribers
4479 on Twitter
Subscribe! Feed reader E-mail

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

Short URL: http://sachachua.com/blog/p/5160

17 Responses to “Subversion: Restore deleted files”

  1. 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.

  2. 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.

  3. 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

  4. 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

  5. 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

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

  7. 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

  8. Thanks for sharing! =)

  9. [...] play ball, and returned path not found. More googling ensued and pgier, commenting on a post at Sachachua supplied the following code (which worked, again substitute the revision and paths as [...]

  10. 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).

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

  12. 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

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

  14. 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.

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

  16. 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

  17. [...] links: http://sachachua.com/blog/2008/09/subversion-restore-deleted-files/ http://www.mokisystems.com/blog/recover-a-deleted-file-in-subversion/ [...]

Comment, share a thought, ask a question...

Please comment as you, not your organization.





On This Day...

  • 2011: Monthly review: June, July, and August 2011 — Oh dear. This is turning into a quarterly thing, which tells me that I need to figure out what I [...]
  • 2011: Back to school, back to study groups — We started our first study group session on Friday with a quick review of multiplication. J- and V- warmed up [...]
  • 2010: Welcome, listeners of the Taking Notes podcast! — (If you haven’t listened to this morning’s podcast where Bruce Elgort and Julian Robichaux interviewed Luis Benitez and me about [...]
  • 2010: Tips for entrepreneurs — SCHEDULED: 2010-09-17 Fri 08:00 One of my role models is leaving IBM to explore the world of entrepreneurship. [...]
  • 2008: The Road to Me 2.0: How I Was the Chosen One « Personal Branding Blog – Dan Schawbel — In The Road to Me 2.0: How I Was the Chosen One, Dan Schawbel writes about how he got a [...]
  • 2007: Early morning walk — I went for an walk in the cool morning air. I got halfway through a book while walking through High Park. [...]
  • 2005: Oooooh. Linux Journal editorial calendar up! — Check out the Linux Journal editorial calendar to see what they’re planning to feature next year, and you’ll immediately see [...]
  • 2005: More about call centers — A lot of people look down on call centers. I think that’s wrong. I think there’s dignity in the work that [...]
  • 2005: The Great Merge — Thanks to Yann Hodique‘s totally awesome backend structure in hodique@lifl.fr—test/planner—merge—1.0, the distinction between planner/emacs-wiki and planner/muse is on the way to [...]
  • 2005: Remembrance agent for GUIs for the Mac — Onlife looks ubercool. Onlife is an application for the Mac OS X that observes your every interaction with sofware applications such [...]
  • 2005: Pfft. Open source isn’t much better at dealing with this. — jsgotangco but the babes where fun!!!! *hides* sachac And people wonder why there aren’t many girls into IT… ;) jsgotangco girl jsgotangco clair hasn’t told you about [...]
  • 2005: Phonecards — Turns out that the phonecard I’m using gives me great rates for calling cellphones in the Philippines, but has ridiculous surchanges, so [...]
  • 2005: Microsoft booth babes — Regarding the latest LinuxWorld Philippines: happy_eclair there were so many babes at the MS booth sachac <roll eyes> It figures. Of all the sneaky, [...]
  • 2003: Lecturing on lecturing — We recently did student evaluations. I must be the only teacher in my department whose students want more lectures… ;) In [...]
  • 2003: Dr. Queena Lee-Chua’s Metrobank Outstanding Teacher acceptance speech — Proud to be Teachers By: Queena N. Lee-Chua, Ph.D. Ateneo de Manila University (Response during the 2003 Metrobank Outstanding Teachers Awards, Sept. [...]
  • 2002: (Wed Sep 18:06 2002, *Article*) — http://cedet.sourceforge.net/semantic.shtml
  • 2002: (Tue Sep 17:18 2002, *scratch*) — - talk to Selwyn and Mike Mapa looking around corners military applications ask selwyn about sci fi story six tracks – egovernment, wireless isolated lab [...]
  • 2002: (Tue Sep 17:25 2002, 2002.09.17) — That machine runs on Linux. how do i retrieve
  • 2002: (Tue Sep 17:03 2002, *mail*) — I feel so stressed out. Traffic will do that to a person – traffic and the thought of being late. [...]
  • 2002: (Tue Sep 17:45 2002, 2002.09.17) — In the elections of 1949, Quirino is the candidate of the liberal party. Laurel nationalista party. Quirino wins with 52% of [...]
  • 2002: (Tue Sep 17:25 2002, *eshell*) — 1.3 Goal. Praxis. If we remain on the theological reflection moment, what happens – if there is no action? detachment
  • 2002: (Tue Sep 17:47 2002, 2002.09.17) — 2. Desire. God’s plan in social reality. lways keep your users in mind. Always remember why you’re doing a system – [...]
  • 2002: (Tue Sep 17:55 2002, 2002.09.17) — Assumptions: Social Analysis in the context of the pastoral cycle 1. Before you can make a meaningful relevant social analysis, there [...]
  • 2002: (Tue Sep 17:33 2002, 2002.09.17) — Web development – cartolina, permanent marker Objectives: involeve them in the design process and show them how the design process works. Start [...]
  • 2002: (Tue Sep 17:56 2002, 2002.09.17) — Problem-solving focus for CS110. What is traditionally covered? Stacks, queues, trees, O(n), recursion, dynamic programming, searching, sorting.
  • 2002: (Tue Sep 17:49 2002, 2002.09.17) — What will I talk about later? - my wearable computing project One of these days I really should improve the emacspeak interface [...]
  • 2002: (Tue Sep 17:50 2002, 2002.09.17) — Sept 19: 20 pt quiz on article 45, 46, 48 (social analysis folder Sept 26, oct 1: bonus quiz: Synthesis folder Oct [...]