How to recover a deleted file in Eclipse
Today I accidentally deleted a file in Eclipse. I didn't even know I did it until I ran my code. I am not even sure how I deleted it. My best guess is the current focus was on the project explorer and some strange key combo sent the file to the netherworld.
Eclipse, as you probably know, does not use the Windows 'recycling bin'. As luck would have it, the file was long, complex, just freshly debugged and not yet in version control.
I was able to recover the file by using the Restore from Local History option located in the context menu inside the project navigator.
"What?!?! I thought that only worked for files, not directories..." , you might say. I thought the same thing. Thankfully Eclipse is smart enough to know that when humans are behind the keyboard, expect the unexpected.
Try it and see for yourself.
Disclaimer: Not responsible for damage resulting from deleted files. Delete your files at your own risk.The posting and use of this information is governed by the laws of Uzbekistan. All legal proceedings must be filed in person on the third Tuesday of July at 1342 Uzbek Lane, Tashkent Uzbekistan. Accidentally deleting files can result in one or more of the following horrible incidents:
- You could miss deadlines
- Your boss could fire you
- Your computer may stop functioning
- Your computer might function incorrectly
- Your computer could burst into flames
- All the beer in your refrigerator could disappear
- A puppy could die
There are no comments for this entry.
I have always wondered if there was a way to do this.
@steven
Yeah, I am a large fan of subversion. I use it on all my personal projects and recommend it to all my clients. What I meant in the post above by "just freshly debugged and not yet in version control." was that while the file was looking really good, I had not committed the file as it was just yet. I do not line checking in versions that do not run.
I am, however, open to ideas. At what stage of developing a component do you commit?
DW
Restore from Local History works like a charm. Except when you accidentally delete an entire project and also check 'also delete contents'.
I did this the other week, and there's no coming back from it.. :-(
> At what stage of developing a component do you commit?
>
Depends....
If I'm working in a branch I tend to hold on to changes until they are working. This is because most times branch changes are pretty small bug fixes and minor functional additions, so it doesn't actually take that long to make those changes anyway.
If I'm working in the trunk, I try to remember to submit in every couple of hours. Usually when I've added some discrete bit of functionality (whether it works or not). I've had issues in the past where I've wanted to go back to a revision in the local history only to discover that its outside of the local history range. I tend to work on the premise that trunk, while it should work, is mostly likely going to be broken.
Hi,
Thats really made for me most useful, unfortunately number of files get deleted I was really totally sad, whether is it any way to get back my very suspecious files but after googling ur response given me a very very useful way to recovered it very easily. After all just I wanted to say Eclipse is really a powerful tool.
Very very thanks to you for your such valuable posted response....
Really greatly helpful. I saved around 48 hrs work with this feature.
Thank you so much, I only knew the context menu for an existing file. You saved me about 18 hours of work!!!
Thank god for this feature :D I'm new to svn and I didn't realize that revert deletes any packages that aren't in version control yet. So when I clicked revert to fix some minor issue, I lost a package with about 50 hours of work invested in it. It took me 30 minutes to find this solution and now I'm saved from the wrath of my superiors :] :]
Hell yeah, your tip saved the day, thanks!
Thank you soooo much. I was looking everywhere for how to get my file back. You are the MAN!
I had the same problem and solution as well. I !swear! eclipse ate 3 of my files, I just wish I knew how to not repeat it.
Just had to empathize w/ you!
You made my day ! Thanks
man I love you! (and eclipse off course :)
Mate, I love you as well! I know exactly how I did it...I was pressing ctrl + z (undo) thinking I was undoing changes in my source code but in fact my focus was on the project view (my files) and it was undoing the ones that I created...Eclipse should sort this issue out as I'm sure many have made this mistake and haven't been lucky enough to find this solution!
OH MAN...you are a lifesaver!!!! I just checked my work into Dev and it said a file was missing...evidently I deleted it accidentally...first time for that one...THANKS for posting this!!!!!
Thanks for the post, it was very useful.
Yes, Carl is right! I second him on the CTRL + Z issue if pressed in the Navigator pane, and it's a "pane" in the arse cause it really does undo changes made at the file structure level (creation / renaming), which are very common tasks accomplished by a developer. However it does not undo the deletion of files, just as well as it does not magically redo the deleted files (by accidentally pressing ctrl + z) if you think of trying ctrl + y to restore.
In my opinion this is pretty critical (deleting files) and it should be simply fixed by showing a dialog box, similar to the one shown when you're trying to delete a file by pressing the "delete" key.
you're a lifesafer, THANKS!
Thank you man! You've just saved 5 days of my life!
THANK YOU! THANK YOU ! THANK YOU ! THANK YOU! MUAH! MUAH! MUAH!





Sez : Dan Wilson
January 18, 2008 8:26 AM
Suscribe
Follow Us
Contact
Subversion, Subversive/Subclipse and the Team menu are also pretty useful for making sure you don't lose files or changes. ;)