Using Local History to restore deleted files
January 28th, 2008 by Irina MegorskayaSuppose 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:


January 28th, 2008 at 7:06 am
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!
February 5th, 2008 at 11:11 am
Hi Ken !
Thank you very much for your positive feedback
September 17th, 2010 at 8:31 pm
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!!
December 30th, 2010 at 9:14 pm
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