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.
Add Comment Subscribe to CommentsI 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!
Thanks !
Thanks a lot. Once again a life-saver.
Hey man! You probably saved me couple days!! I'm sending you some virtual packs of beer!!!! :)
Thanks, with such a clear explanation, it's no wonder you're the first google result for "eclipse undo delete".
THANKS A LOT...............
Aww, this was a really quality post. In theory I’d like to write like this too – taking time and real effort to make a good article… but what can I say… I procrastinate alot and never seem to get something done.
Thank you. I agree there should be a redo of your undo though...
You are a genius! I had just accidentaly -and idiotically- lost 25-30 hours of work. You saved my day. Thanks a million.
I'm more and more in love with eclipse every day.
You are my HERO!! I love you man! You saved me about 3 days of work!
Found this page after rewrote the class I accidentally deleted but this will be helpful in the future in case of a mishap.
Thanks.
there is a bug in subversive where if you're checking in a file for the first time with some revisions it sometimes will delete the new file. This happened to me about 15 minutes ago with a file I put a good amount of work in to... and you saved my day. Thank you!
Thanks Man
I almost slit my wrists while trying to figure out how to recover files I didn't even delete.
Thank you for this page!
Phewww... thanks a loot for this ... I was blank for a minute when I accidently deleted the file I was working for 2 days ... !!!
Site information useful, I believe you must spend a lot of time in it, thanks so much. Looking forward to receiving new changes next time.
hey! thanks alot! saved me a whole day of programming :D
Thanks a lot
Thanks man, saved several hours of work.
Echoing what everyone else said. Thank you! You saved me many days of work (and my sanity)!
Thanks you saved me hours worth of work
Thanks, This is blog was really helped me a lot.
Thanks, saved my day. I literally crossed my fingers while restoring a deleted file.
Big Thanks for that tip!!!
saved my life... tnx
Thats really Best!!! It Saved a big loss
Saved my butt!!! thanks a lot..
Saved my life man!!!!! I had lost my 3 days of work... Thanks a lot... :)
Saved my life, thanks!
Hi, if i deleted the whole project, how can i recover it.
please help me
:(
Wow! Three and a half years later, and your post is still saving people! Thanks! (Only about four hours of work for me, but man, that's enough!)
Indeed, thank you sir. Saved me two days of work. :)
Excelent !!!
You saved me 2 hours of work !
Thank you
You saved me. Thank you so very much!!
Many many thank you. You save my work
It's friday evening 5pm and you just f***ing rule 'cause my week end was about to be a bad one!
THANK YOU DAN !! really appreciate the folks who post solutions :)
Lucky you and me :)
Thank u very much for your valuable support.
I was about to suicide that i have accidentally deleted my algorithm.
Thank you very much!
You just saved my Day!
Thanks. Saved my late night journey. Thanks a lot.
Thanks! I was already opening the window ready to jump :P
I was committing to SVN (Right Click) and hit the delete instead of add!! I was nearly sick as it was over 1200 lines of a major module!! You saved my life.. Did not know that Eclipse did this as I rely on SVN so much.
Thanks you saved me!
Thank You Very Much....Thank's a lot...!You Save me...again Thank You...!
Saved at the eleventh hour!
THANK YOU AND ECLIPSE VERY MUCH!!!
you saved hours of work to me
:-)
Another helped person!
Great Tip!! Saved my day :-)
Thank you!!
Thanks a lot!!!!! You saved my life!!!!
Damn .. u save my day!
God bless you!
Lifesaver post! THANKS!
Thanks a lot!!!
You saved me hours of working, Thanks !!
Awesome man, thank you very much.
wow.. you saved me man..Thanks a lot!
Godsent post!
massive thanks, you just saved me a huge amount of time. much appreciated!!
you save my health because without this post I will have a big headache because I just delete my java code which contains hundreds of lines wuch took me a lot of much time to write and debug
thanks buddy
Thanks this really saved me a ton of time!
This saved my butt! 6 hours of work, I was freaking out. Looks like I should commit to SVN more often.
Thanks a lot..:-):-).. I'm happy i got my files back.. Thanks again..:-):-)..
Thanks...........
was about to wrap up my work and before checkin i realized i did delete a file accidentally... my heart dropped...but here I am Smiling.. Thanks bunch
Thank a lot!! this saved my entire week's work.
Thank You for posting this, today i recoverd code thanks to this article.Saved lot of time :)
1000 Thanks !!!!
Thanks dude. This thing is still useful now in 2013
You are a life saver!!!! I was being lazy and not committing a new mvn project. You saved me a week worth of work. I won't be so careless again.
Awesome blog! thanks for ur useful blog...
U r Awesome...Tanks a lot!
No Words!
you just save my life!!!!
Whew! Thanks! Saved me!
Thank you very much!!!
A pint of beer from Lviv. Thank you MAN!!!
Thanks so much. A life saver!
Exactly what I needed after issuing 'svn --force remove ..' Thanks!
Hi,
Thanks very much
It works greatly..........
Thanks a lot! This saved my day
It works.. Thanks Dude.. You saved my day...
Thanks! Saved my ass :)
Thank you very much.., saved me
Hi,Thank u thank u very much...i deleted one file when my project is about to release.because of that release got delayed for 2 days.i was using project explorer now in navogator i got that file...am very thank full to u...thanks alot again..
bye
Thank a lot
Thank you so much. you've saved 3 days of my work. Once again thanks a lot
Bless you Dan Wilson, whoever you are! I love you!
Thanks you so much dude
thanks a lot.... it helped me to recover data deleted from my java file which is very important part of my current project
Thank you so much! I didn't think that it is possible to recover a deleted file within Eclipse but I gave it a try and finally it saved a lot of work for me :)
Thanks again!
Thanks A lot
Thanks for saving me too! I usually don't commit until a small feature is complete, and I deleted a new file by accident.
Thanks! This saved me BIG TIME!
Awesome help! Just saved my days of work. :)
thanks a lot
You just saved me hours of work, thank you very very much :-)
Thank you, this saved my project with 2 weeks of work.
Thank you so much! I used this feature to recover some configuration files of a deleted Server... Awesome!!!!
Subversion, Subversive/Subclipse and the Team menu are also pretty useful for making sure you don't lose files or changes. ;)