Thursday, June 28, 2012

SVN - Restore a Deleted File

1. Get the Svn version that matches the file deletion
Go to the deleted file directory and

>> svn log --verbose

------------------------------------------------------------------------
r23332 | niteshk | 2012-06-28 11:33:14 +0530 (Thu, 28 Jun 2012) | 1 line
Changed paths:
   D /crap/branches/Crap.java
   M /crap/branches/adc.java

deleting Crap file
----------------------------------

revision # 23332 is the revision version corresponding to the deletion of Crap.java
Choose any earlier verision, just intelligent guess, that could have contained the file

Lets choose a verison earlier = 2332

>>
svn update -r 2331 Crap.java
 
This command fails to do the expected, so lets try another one.
 
>>
svn copy -r 2331  https://{URL}/Crap.java . 

This too fails !!

So the final one. Add revision version to the Url

>>
svn copy -r 98 https://{URL}/Crap.java@2331