Using Local History to restore deleted files

Posted on by imegorskaya

Suppose you have accidentally deleted a file from your project, and want to have it back. Sure, you can restore it using the file system, but IntelliJ IDEA suggests a better way to do it, without leaving the IDE.
This is where IntelliJ IDEA’s local history on the project or folder level comes to help, preserving all modifications that affect the nested files, including the changes to the contents and to the file tree in general. Each change is marked with its time stamp, revision, and action description. Unlike version control that keeps track of the committed revisions only, the local history preserves all local changes you make as you edit, compile or test, during few days (it is up to you to define how long you want this history to be). This “personal version control” will help us restore the deleted file.
In the example below, a file Lost.txt has been deleted from the FontChooser project. Let’s try to restore it. Go to the Project tool window and right-click the project node or just a folder, where the file used to exist:

On the context menu, choose Local History, and click Show History on the submenu:

The local history view for a project or folder shows you everything that you have done during the last few days. In the Action column of the lower part of the dialog box, select the action you want to roll back. In our case, this is the “Deleting” action. So doing, the upper part of the dialog box shows the tree view of changed files.
If you want to restore the deleted file only, regardless of the other changes that have been done since then, you can select the file Lost.txt in the tree view and click the Revert button on the upper toolbar. The file will be restored silently.

A different situation occurs, if you want to restore the deleted file and the whole project or folder state as of a certain revision. In this case, place the cursor on the revision prior to the “Deleting” action, or on the action itself, and click the Revert button on the lower toolbar. If the other files have been changed since the “Deleting” action, you will be prompted that the other changes will be reverted too. Look again at the Project view — our file is here:

Technorati tags: ,
Comments below can no longer be edited.

172 Responses to Using Local History to restore deleted files

  1. Ken Orr says:

    January 28, 2008

    This feature saved me! Our source control system devoured one of my files and left not a trace of it behind. IntelliJ’s local history saved me, as it new the file was there before, and let me salvage its contents.

    This is a fantastic feature!

    • James Nurse says:

      March 9, 2018

      Bump! This is the best feature I’ve ever seen in an IDE

      • Gavriel C says:

        July 25, 2018

        Yes, i agree !!!

      • Arpit Shah says:

        August 31, 2018

        same here, I was under assumption that I’ve lost files and prepared my mind for re-work and then found this as a surprise. πŸ™‚

        • TMD says:

          May 1, 2019

          I was in the same boat. What a great feature!

      • Lakshmana Battula says:

        May 2, 2019

        this feature saved my day. Kudos to intellij

    • Steve says:

      March 22, 2018

      This feature just saved my bacon too!

    • Alexander Salazar says:

      May 3, 2018

      AWESOME, it saved my.

    • Carsten says:

      December 1, 2019

      Same here, although I have to admit that, in hindsight, my VCS did exactly what I told it to do :/

      This feature made my day, and I literally cannot wait to tell my colleagues about it. Thank you so much!

  2. Irina Megorskaya says:

    February 5, 2008

    Hi Ken !

    Thank you very much for your positive feedback πŸ™‚

  3. Mike D says:

    September 17, 2010

    Hey! Major thanks for posting this — you just saved my entire week of “uncommitted” work. And to think the IT guys said I was SOL. You rock!!

  4. Rob says:

    December 30, 2010

    Hello,
    I have a disaster recovery situation I’m in the middle of, and wondering if this feature might help me out. I actually lost several project directories, whole and complete. Am trying a number of things at the moment, but I’m du’ing against the .Intellij10 directory and I see a phat system/caches directory; I’m convinced my local history is just locked up in there.

    Is there any way I can access this cache? I’ve started and quit IntelliJ only once since the incident; when I loaded it up (of course) it couldn’t load my last project because it didn’t find it; and it wasn’t available in “Reopen projects->” list…

    Any thoughts/help would be appreciated!

    Rob

  5. Someone says:

    April 19, 2012

    Thank you for this amazing feature!
    Just recovered two days work…

  6. Alexander says:

    April 6, 2013

    My source directory was completly removed! And I get all code back with this amazing feature… THANK YOU!

  7. Frank says:

    June 15, 2013

    Now this is what I call a *seriously* butt-saving feature. Thank you. Bleary eyed and tired I accidentally wiped out a directory of important files, and then synched with my production server, which of course wiped the files out on the server. I spent all day trying to recover them with search and recovery programs. I was just about to give up and jump off a cliff when I poked around and found the local history. I recovered everything and restored close to a month’s worth of work.

    I learned two lessons:

    1) PHPStorm rocks.
    2) Only idiots work without some sort of versioning system.

    Thank you for adding this excellent feature.

  8. mike says:

    June 18, 2013

    Thanks for this! I also accidentally removed a whole day’s work with a misplaced git reset, and thankfully, I was able to restore everything with this feature.

  9. hangtwenty says:

    July 16, 2013

    this just saved a week of work. thank you so much.

  10. Suseika says:

    September 27, 2013

    Helped me to restore a couple of files that appeared to be untracked by Git after a sudden outage. Praise IDEA!

  11. Oleg says:

    November 12, 2013

    You are the best, thanks for this option, it helped me πŸ™‚

  12. Nicholas Pickering says:

    November 19, 2013

    Local History has triumphed again! Without it, I would’ve lost 3 days worth of work. Thanks, IDEA.

  13. ed austin says:

    January 13, 2014

    Fantastic!!!
    Saved a whole evenings work that would have been real hard to replicate!!!
    You guys rock!!

  14. Calum says:

    March 16, 2014

    I love this feature. Just saved me from redoing a few hours of work. Thanks!

  15. Ahrar says:

    March 31, 2014

    great feature πŸ™‚ Thanks

  16. Shaun says:

    May 21, 2014

    SAVED! awesome feature!

  17. Itay says:

    June 25, 2014

    Great solution,
    Thanks

  18. grub says:

    July 17, 2014

    Saved me two days!
    Thank you!

  19. gheorghei says:

    July 28, 2014

    A nasty commit to SVN wiped out a fat import script AND its output. Two days of work, and I only had hours until the life-changing demo of our product.

    Thank you, thank you, thank you!

  20. dmitiryl says:

    August 19, 2014

    Woups… saved my evening)

  21. Russ says:

    September 24, 2014

    This feature just saved my work, my project, my marriage, and my life.

  22. Mateo says:

    November 7, 2014

    Years and years of saved work!
    You rock guys!!

  23. Randy says:

    November 11, 2014

    Thank you for this! Accident delete the file and save my time! I should have commit the files first.

  24. Seyi says:

    January 18, 2015

    Killer feature. One more reason toy IDE’s don’t stand a chance!

  25. Ben Haran says:

    January 22, 2015

    Reading through all the comments really made me happy now, look at all those people who’s work is saved!

    Of course, I arrived here, after it save one of my files…

    And good job πŸ™‚ I hope it doesn’t cost much in performance!

  26. John Pfeiffer says:

    January 26, 2015

    The best kind of software feature, crash protection! Next time I promise I won’t wait so long to commit and push πŸ˜‰

    (AND remember, git commit -a -m does not add completely new files)
    “-a, –all
    Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.”

  27. Fernando says:

    February 17, 2015

    +100000 from my side!!!
    This feature just saved me loads of time trying to recover from the backup after an accidental rm *

  28. Urosh says:

    March 10, 2015

    Thanks so much for this!

    I did a backup of a project I was working on but forgot to save a file I was modifying locally. So the backup did an overwrite over it and I lost all my work.

    Thanks to this I got my old file back and saved a lot of time!

  29. Zsolt says:

    May 7, 2015

    This saved my day work! I did a git reset –hard before I commited my changes and this was the only way to restore my files!

    Pycharm (and jetbrains) rock!

  30. gReg says:

    May 22, 2015

    Thank you so much! What a nice feature.

  31. Lee Grey says:

    May 25, 2015

    This feature saved me an entire evening’s worth of work. IntelliJ is the best!

  32. Lukas says:

    June 28, 2015

    Saved my life right now – Intellij best IDE of the world!!

  33. Dmitry says:

    August 7, 2015

    Wow, thank you. Restored hours of written code in a file I some how deleted without knowing.

  34. Sampene says:

    August 27, 2015

    I just got saved with this feature.Amazing, Thanks

  35. Ola says:

    August 29, 2015

    Thanks buddy you saved me….

  36. Adnan says:

    September 3, 2015

    Thanks…

    You saved my life…

    It was amazing to recover deleted file… just 13 recoved files….

    πŸ˜€

  37. Pat Garcia says:

    September 7, 2015

    Dude!! i know this thread is old as hell but you just saved my butt. Thanks!!!!

  38. Andrew Nyago says:

    September 11, 2015

    This saved my life too.

    Had been working on a File the whole day (more-over if Friday) when a power outage caused my file to “disappear”.

    This feature saved my day and my weekend.

  39. Moushumi says:

    September 15, 2015

    how to retrieve a file a new file which is just created, if it gets deleted due to system crash.

  40. choirul anam says:

    September 23, 2015

    Thank’s very much, this solution is save my time. I was lost my php project located under bin-debug folder because affected by ‘cleaning before compile’.

  41. Suresh says:

    September 24, 2015

    Thank you so much IntelliJ, you saved my valuable 5days work.

  42. Ademola 'Jeda says:

    October 26, 2015

    I was down after I deleted my repo my mistake but this tutorial saved my day!!!

    many thanks

    • Maksim Sobolevskiy says:

      October 27, 2015

      We are really glad to hear this!

  43. Alexander says:

    November 4, 2015

    Thanks. You saved my life!!!))

  44. Andreas Greece says:

    November 19, 2015

    I was in cold sweat for an hour and then I found it. 2 weeks of hard work saved !! Thank you for this!

  45. John Milo says:

    November 23, 2015

    Now I love Rubymine even more.

  46. Ruchir says:

    November 26, 2015

    Thanks a lot… +1

  47. Alexandr says:

    November 26, 2015

    Amazing feature. Thank you a lot. You are the best high skilled engineers because you have made up this thing!!!

  48. Jemima says:

    December 5, 2015

    You saved my ass! I love you!

  49. Shon Diaz says:

    December 13, 2015

    I could cry… i accidentally rm a script file that was not yet in the repository. It was the same name as a log file and powershell tab name completion screwed me! I googled a data recovery that did not work. I was about to give up hope when i saw this thread.. LIFE SAVER! I was sold before because of excellent nodejs support, but now this is my favorite ide. (sobs)

  50. mona says:

    December 17, 2015

    My butt was saved πŸ™‚ I like how this article has lasted 6 years with all the happy commenters!

  51. Loredana Elena - Radu says:

    January 4, 2016

    Is working fine too with CTRL+Z in the Project part not in a file.

  52. Bastiaan says:

    January 4, 2016

    Thank you, thank you, thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  53. Jakub says:

    January 28, 2016

    Save a lot of work πŸ™‚ Thanks!

  54. nathzeleke says:

    February 11, 2016

    I have lost words to express my gratitude for jet brains. You have saved me a lot of work. Thank you very much.

  55. Steve says:

    March 30, 2016

    This feature saved me one week of hard work, phewww…
    Many thanks!!!

  56. Attila Fulop says:

    April 21, 2016

    THIS FEATURE RULEZ!!! πŸ™‚
    It has saved me 3 hours of work that hasn’t been pushed, but overwritten by a composer update.

  57. Abdur Jabbar says:

    April 22, 2016

    +1 for saving my ass. Great feature!

  58. Vinicius says:

    April 22, 2016

    This is indeed a great feature. Just saved me now. Thank you.

  59. Trevor Scheer says:

    April 28, 2016

    Just another person here to thank you for such a wonderful feature. I had already given up and gone to plead with the teacher about losing 3 (full) day’s work when it popped into my head that there may be something in IntelliJ that could save my butt.

    Already a fantastic IDE, but you’ve earned a loyal customer once my student membership is up.

  60. Andrei Ordine says:

    May 20, 2016

    Awesome feature! Saved 2 days of coding

  61. Sami Awwad says:

    May 24, 2016

    Praise the Intellij Gods for this feature!
    I accidentally clobbered a file with a perforce resolve and was able to get it back using this feature.

  62. GJ says:

    June 7, 2016

    This saved my life.. Really thank you!!!!!

  63. Gupta says:

    June 21, 2016

    Thank you for this post!

  64. Sunil says:

    June 28, 2016

    hello,
    i faced a problem of “file.py” deleted from project accidentally, i tried almost all the technique to retrive it, since my VCS was not configured. so i find it very easily by browse console history, and i just copied the whole code πŸ™‚

  65. Krishna says:

    June 29, 2016

    Thanks for the post. Helped us a lot.
    Saved time and efforts.

  66. ktou says:

    July 13, 2016

    Oh really nice feature, you saved me !

  67. Kuanysh says:

    July 26, 2016

    Thank you

  68. Island Pinnick says:

    August 12, 2016

    This just saved me as well! Thank you guys for making suck an awesome product!

  69. marvine says:

    August 19, 2016

    This is Fantastic…

  70. Harry says:

    August 24, 2016

    Love this feature saved me a lot of stress and headache today. Love Intellij

  71. Vineet says:

    September 12, 2016

    BIG BIG THANKS

  72. Bandar Abdulrahman says:

    October 19, 2016

    You save my life, really i mean it.

  73. Arjun CHATTERJEE says:

    October 24, 2016

    The local history feature Seriously Saved me 10 hours of work!
    I wanted to do: rm tmp/*
    But i accidentally did: rm * tmp
    And lost all of my code!

    Thankfully Jetbrains is the Best IDE in the universe, it saved me!

  74. AZOR says:

    November 29, 2016

    + one saved life, I created file starting with A, click on the last file in the folder and remove it .. the wrong one of course…

    Jeden soubor ale na rozmrdani celeho projektu to stacilo..

  75. alex says:

    January 13, 2017

    Oh, I just being saved by this feature as many more before me.

  76. sebastian says:

    January 27, 2017

    I love this feature, I had lost hours of work due to an uncommited git reset –hard!!!!!!!!!

  77. ron says:

    February 10, 2017

    wow !
    life saving feature tyvm!!

  78. random shitty developer that hardresetted by mistake says:

    February 15, 2017

    thank you so much, Whoever wrote this amazing piece of software is the greatest person alive!

  79. VIKAS KOHLI says:

    March 21, 2017

    This feature saved me!
    Thank you PyCharm ide

  80. Francis Kim says:

    March 28, 2017

    What a life saver this feature is!

    I thought my WebStorm was frozen/stuck at first but it just took its time. All my files are restored after a stupid rm *

  81. Edmond says:

    March 30, 2017

    You save me !
    thanks

  82. Alex says:

    April 5, 2017

    Saved my life @ work. Thank you !

  83. Sohail Khan says:

    April 15, 2017

    butt got saved. can confirm

  84. Arashi Funsho says:

    April 25, 2017

    This just saved me a pain of re-writing thousands of lines of code after a power outage tripped my debian pc off. Thanks

  85. Jim Mullen says:

    May 24, 2017

    Worked for me after doing a git reset –hard ! Thanks!

  86. Kavya says:

    June 1, 2017

    Webstorm continues to amaze. Well worth money

  87. Vannat says:

    July 4, 2017

    Great!

  88. abdou says:

    July 7, 2017

    Thanks very much….!

  89. Lee says:

    July 15, 2017

    You have no idea how grateful I am for IntelliJ Idea, I almost got a heart attack when I saw one of my java files disappeared. I came across this article and it really saved me. I had been working on a project this weekend and made so much progress and thought I’d lost it all, but thanks to this intelligent IDE I was able to recover my data.

    I’ve never felt the need to pay for a software product before, but this IDE is so amazing I am going to go ahead a purchase a license for it. It is totally worth the price.

    Thanks once again to the team at JetBrains, you are truly phenomenal.

  90. Haik says:

    July 19, 2017

    thanks, saved me

  91. Ankit says:

    July 19, 2017

    I am using InelliJ IDEA 2016.25 .It gets closed automatically and on reopening all my settings and projects got deleted ,not able to recover also very annoying faced mulitple times the same isse

  92. zenwarr says:

    August 14, 2017

    God bless you, guys

  93. Tuatini says:

    September 5, 2017

    So much thanks for this. This saved me a day of work.

  94. Mark says:

    September 21, 2017

    Praise the lord Intellij is my IDE, feature saved me !

  95. timefrenzy says:

    October 17, 2017

    Thanks for that funcationality, that saved my a lot of work. I accidently deleted the work of some hours.

  96. simpleman19 says:

    October 22, 2017

    THANK YOU SO MUCH

  97. John says:

    November 2, 2017

    Thanks so much u have saved me

  98. Tatiana says:

    November 16, 2017

    Helped me after a dumb gitignore-related accident today. Thanks!

  99. Slava says:

    December 4, 2017

    Omg thanks very much, my ass has been saved

  100. Pavel Vasev says:

    December 18, 2017

    Thank you very much for this feature! You saved 4 days of my work..

    Especially thank you for that you store history outside of project directory. I deleted my project directory because I thought it was pushed to git.

  101. Nikita says:

    May 3, 2018

    I love you guys! You save my four days work!
    I know, I have to commit every day, but… πŸ™‚ Many thanks for feature “Local changes” on folder!!!
    (closer to above situation: I made checkout –force and didn’t think what could be happened)

  102. Sebastian says:

    May 12, 2018

    I accidentally deleted my entire src directory instead of just one header file in it as I was cleaning it up to do an initial checkin to my VCS. Eight hours of work would have been down the drain were it not for this article and CLion.

    Huge relief!

  103. Arg0s says:

    June 1, 2018

    God save your fucking brains!!!

    Thank you so so much!!

  104. Pemedina says:

    June 6, 2018

    And, 10 years after 1st post. this feature keeps saving souls. Hell would be overpopulated without this.

    Phew!!!

  105. Talat says:

    June 6, 2018

    My favorite saver fatureeeeee!!!!! πŸ™‚ thank you thank you !!

  106. Italo says:

    June 12, 2018

    This saved my life! Thank you very much for this feature!

  107. Alireza says:

    June 14, 2018

    this saved me life thanks jetbrains

  108. Tatiana says:

    June 21, 2018

    “Why put this temporary project under source control, I’ll move it tomorrow to another one”. That’s why! Tried to move all project files as a subdirectory in another project and things went terribly wrong.
    This feature saved me two days of work.

  109. krishna singh says:

    June 27, 2018

    Sorry, but it didn’t helped me. I reverted all the changes that I had made but still couldn’t find my web.xml file. I don’t know how it got deleted. I just made changes in my dispacther-servlet.xml file. Then run clean and package in maven. After running package I got the error of couldn’t find web.xml file in the location.

  110. Ahmed Abdeldaim says:

    July 3, 2018

    Oh My God .. What a genius features, i have restored a whole folder with it which saved my life. thanks a lot.

  111. saeed says:

    July 5, 2018

    Really tanks to php storm and u.

  112. Kiril Minkov says:

    July 8, 2018

    Thanks a lot! This is the best idea ever. You rarely need it, but when you do it saves you great deal of hassle.

  113. svarlamov says:

    July 11, 2018

    Awesome feature!

  114. Mikle Talalaevskiy says:

    July 13, 2018

    Thank you

  115. Hamzah Tossaro says:

    July 19, 2018

    Live saver!!

  116. Rana Saha says:

    July 26, 2018

    Thanks. Just saved me a lot of time.

  117. thir13en says:

    July 31, 2018

    What can I say… <3 forever guys!!!

  118. Makkenza says:

    August 27, 2018

    Very useful, especially after the vacation πŸ˜€

  119. Bukky Olawoyin says:

    September 20, 2018

    Phew…

    This saved my neck!

  120. Drew says:

    September 24, 2018

    THANK. YOU. You just saved my project. Thank you so much.

  121. Edwin says:

    September 25, 2018

    Excelente aporte me han salvado la vida!!

  122. Joel says:

    September 25, 2018

    This saved me as well. So thankful.

  123. Jonathan Banin says:

    September 26, 2018

    The person who thought of this should get promoted.
    Seriously, thanks!

  124. Dmitry Shultz says:

    October 6, 2018

    Spasibo!

  125. Mithin Reddy says:

    October 17, 2018

    awesome feature

  126. Mahima Choudha says:

    October 22, 2018

    Thanks very much..

  127. Radek says:

    October 25, 2018

    Thank you! Really excellent feature of IntelliJ!

  128. Wilson Ong says:

    November 21, 2018

    Got back my accidentally deleted files πŸ˜€

  129. Tara says:

    December 19, 2018

    Bless you! I just recovered work I thought I had lost!

  130. AsHappyAs - A new breed of social media says:

    January 3, 2019

    Excellent feature – helped us recover 2 days lost work!

  131. Leandrit Ferizi says:

    February 4, 2019

    Great feature, lots of thanks. Saved a good chunk of my day

  132. Rajyalaxmi says:

    February 6, 2019

    AWESOME..!!! Thanks

  133. Vijay Venkataraman says:

    February 7, 2019

    Saved me. Wonderful feature.

  134. TorbjΓΈrn says:

    February 8, 2019

    I’m amazed that this worked even after deleting the project directory itself – including .idea/ and .git/.
    At first I was annoyed by how IntelliJ immediately closed the files I had open (which contained most of my unpushed work), but with this feature I can understand why!

  135. MAHIMA says:

    February 10, 2019

    SAVED ME

  136. Moses says:

    February 12, 2019

    Please any idea on how to recover lost files on pycharm

  137. Silvio ClΓ©cio says:

    February 24, 2019

    Dear JetBrains developers.

    I accidentally deleted an entire folder containing many changes (about 9 hours of work) unpushed to the online repository. After a lot of tries using many Linux tools, I had the idea to search any history feature in CLion and I found this post. Oh my, *YOU SAVED MY LIFE!* :’-)

    Thank you very much for your awesome tools!

  138. Sankarganesh says:

    March 8, 2019

    The critical feature of IDE than auto-complete, saved my work.

    Long live intelliJ !!!

  139. Sergio says:

    May 6, 2019

    Made my day πŸ˜€

    Thanks IntelliJ!!

  140. Rodrigo Boratto says:

    June 21, 2019

    Thank you JetBrains! Life saver!

  141. Yeet says:

    July 11, 2019

    I did this and It corrupted zip/rar files, mp3/wav. How do I fix that

  142. Melvin Yin says:

    July 23, 2019

    Accidentally did a `shutil.rmtree(project_directory)` while debugging. Last commit was nearly a day ago (I know). This just saved my one whole day of work, thanks guys. Seriously, thanks.

  143. Jacob Schneider says:

    July 26, 2019

    I accidentally deleted my *Whole* project. Thank god for IntelliJ, I would have screamed. I just wanted to drop a comment to say thank you for the gods at Jetbrains. What a bunch of legends.

  144. Pablo says:

    July 26, 2019

    Best feature ever!

  145. ps says:

    August 19, 2019

    AMAZING feature!!!

  146. ps says:

    August 19, 2019

    Thank you.. This is amazing feature..

  147. serg says:

    September 5, 2019

    THANKS!!!!!!!!!!!!!!!!!!!!YOU SAVE ME!!!!!!!!!!!!!!!!!!!!

  148. raftaar1191 says:

    October 1, 2019

    Thank you very much

    You save me !!!!!!

  149. someone says:

    October 8, 2019

    Thank you!!!

  150. Anton says:

    November 8, 2019

    awesome feature!
    Thank you!!!

  151. jake says:

    November 30, 2019

    Thank you so much!!!

  152. Lucas says:

    December 3, 2019

    CHRIST THIS THING SAVED ME.

  153. Peter Westlin says:

    December 10, 2019

    Local history is still going strong – woohoo!

  154. Nikolay says:

    December 12, 2019

    This feature just saved me 30 hours of work! Brilliant, thank you!

  155. Maheep says:

    December 17, 2019

    Wow Thanks
    Saved me!

  156. Ry says:

    December 18, 2019

    Just turned my panic attack into time for a beer. Cheers to this lifesaver!

  157. Sandeep says:

    January 17, 2020

    This is best feature thanks

  158. aykon says:

    February 28, 2020

    Where can I sent Beer and Cake???

  159. Sweta says:

    March 9, 2020

    This saved me!!

  160. Athanus says:

    March 24, 2020

    Thanks buddy, saved my whole project

  161. Partho says:

    March 24, 2020

    thanks a Lot jetBrains..

  162. Jose says:

    April 24, 2020

    This 12-year-old feature just saved me, thank you JetBrains for creating such good products.

  163. Razvan says:

    May 20, 2020

    JetBrains rocks! I just recovered the work I did for the last 2 days!

Subscribe

Subscribe for updates