Recover a deleted file in Subversion
May 29th, 2008 By: brianSVN is great for keeping our projects under tight control. Occasionally, we have the need to get something back that was deleted in a previous revision. So I can remember how to do it next time, here it is:
$ svn copy -r 1234 url/to/deleted/file path/to/recovered/file
This will copy the file at the revision specified to the new file in the “restore to path” part. You can find the revision by doing an ’svn log –verbose’ of the directory it was in. That’s all there is to it!
My theme seems to be restoring and recovering… is that a bad thing?

Moki Systems is seeking a full-time Ruby on Rails developer. The person should be a self starter, willing and able to figure things out on their own. Applicant should have experience with Ruby on Rails, MVC programming concepts, MySQL and/or PostgreSQL experience and the ability to learn new technologies. Any additional...
May 1st, 2009 at 1:36 pm
If you are giving the repository url, the -r or –revision parameter doesnt work.
instead specify the old revision by appending @revision-number to end of the old file url.
svn copy svn://repo-path/file-path@old-revision-number relative-path-to-new-location
example -
cd working-copy/mydir
svn copy svn://www.example.com/myproject/mydir/myfile@21 .
will copy the the file ‘myfile’ from revision 21 into the current directory.
November 12th, 2009 at 10:26 pm
Your forgot a hyphen in the svn log command:
svn log –verbose
Thanks!
January 14th, 2010 at 2:56 pm
I was not able to use the @revision syntax, but -r worked just fine.
The following command restored a deleted README file (with log entries back to 1993!) in my current working directory:
svn copy -r http:////README .
– Thanks for the help!
January 14th, 2010 at 3:01 pm
Sorry, but that last post got scrambled; blame it on careless use of angle brackets.
Hopefully, this version of the command will come through unscathed:
svn copy -rrevision_number_where_deleted http://svn_machine_name/svn_repository_path/README .
February 19th, 2010 at 7:04 pm
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.