PyCharm How to restore deleted file

PyCharm can easily restore deleted files from your Project by few clicks without even using 3rd party tools or file system. The way to get back accidentally deleted a files from your system:

  • Go to Project Pane
  • Right Click
  • Select Show history / Local History
  • You can see all changes in the current project
    • impacted files
    • timestamp
    • Action
  • Select the operation which cause the deletion
  • Revert

In my case I did some changes on the master which were supposed to be done in different branches. So I created the new branch and did commit and push. Then I switched back to the master where I saw the same files except one which made me suspicious but I didn't pay much attention.

Then I reverted the local changes (which was equal to deletion) a few minutes after I found my mistake. Several hours of work, dozens of Python lines, my brilliant logic were lost.. Luckily I remember that there is local history in PyCharm. Lucky me my code was saved. Thanks PyCharm!

Note: It works even when the PyCharm is closed and reopened.

Step 1. Open Local history

To start let's open all local changes in the project by:

Step 2. Preview changes

Next step is to find the changes where the file is deleted or modified.

Step 3. Revert the deletion of the files

Finally you can revert the deletion or modification.

This great feature is available also in IntelliJ, PhpStorm, WebStorm etc.
Good luck saving your code!