Beyond Ctrl+Z: Using IntelliJ IDEA Local History for Emergency Recovery
Recover deleted files and undo destructive refactors using IntelliJ IDEA's Local History, a built-in safety net that tracks changes independently of Git.
19 Dec 2025, 21:14 UTC

The problem: Losing code before the commit
Every developer has experienced the panic of a "vanishing" file. Perhaps you performed a destructive refactor, accidentally deleted a source file, or realized that the changes you made three hours ago were actually better than your current version. If these changes weren't committed to Git or SVN, a standard undo (Ctrl+Z) is often useless—especially if the IDE was restarted or the file was deleted from the disk.
The safety net: Local History
IntelliJ IDEA maintains a feature called Local History, which acts as a high-frequency, automated backup system. Unlike a Version Control System (VCS), which requires manual commits, Local History automatically tracks every change made to files independently of your Git status. It stores these snapshots in a proprietary internal database within the IDE's system folder, allowing you to roll back to specific timestamps regardless of whether you ever staged the code.
How it differs from Git
While Git tracks the evolution of a project across a team, Local History tracks the evolution of your specific workspace on a single machine. It is designed for short-term recovery and auditing, not for long-term archival or collaboration.
Worked Example: Recovering a deleted configuration file
Imagine you accidentally deleted application-dev.properties from your project root and emptied your OS trash bin. Since the file was never committed to your repository, Git cannot restore it. Here is how to recover it using Local History:
- Target the Parent: In the Project tool window, right-click the folder that previously contained the deleted file (e.g., the
src/main/resourcesdirectory). - Access History: Select Local History → Show History.
- Identify the Snapshot: A dialog opens showing a timeline of changes. Look for the entry labeled "Deleting" or a timestamp immediately preceding the deletion.
- Compare and Restore: Select the snapshot. The IDE will display a side-by-side diff viewer showing the file's state at that time versus its current (non-existent) state.
- Revert: Right-click the deleted file in the history list and select Revert. The file will be recreated on disk exactly as it was at that timestamp.
Trade-offs and Technical Limitations
Local History is powerful, but it is not a replacement for a formal backup strategy. Consider these constraints:
- Retention Limits: The IDE does not keep history forever. By default, snapshots are purged after a set number of days. You can verify or change this in Settings → Appearance & Behavior → System Settings → Local History.
- Machine Bound: Because the history is stored in the local system folder (e.g.,
~/Library/Caches/JetBrains/on macOS or%LOCALAPPDATA%\JetBrains\on Windows), the history does not follow the project to another computer. - Resource Overhead: Maintaining a detailed database of every keystroke and file change requires disk I/O. In environments with extremely limited disk space or slow HDDs, this can occasionally impact IDE performance.
Practical Verification
To ensure your safety net is active, you can perform a quick check:
- Create a dummy file named
test_recovery.txt. - Add some text, save, and then delete the file.
- Right-click the parent folder, select Local History → Show History, and verify you can see the deletion event and revert it.
If the history is empty, check your disk space and verify that the IDE has write permissions to its system directory.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.