Subversion: Restore deleted files

Posted: - Modified: | development

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

You can view 7 comments or e-mail me at sacha@sachachua.com.

7 comments

Chris MacGregor

2009-12-17T07:18:15Z

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

svn copy http://svn.mycomp.org/repos... 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).

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

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

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

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

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

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

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