When Git Isn’t Enough: Using PhpStorm’s Local History for Quick Recovery
When your last commit is a few hours away, PhpStorm’s Local History can recover uncommitted changes. Learn how to use the IDE’s snapshot feature to restore deleted code and understand its limits.
25 Jul 2025, 12:34 UTC

Problem: The Uncommitted Gap
Developers often work on a feature, run tests, and discover a bug before committing. If a refactor or accidental delete occurs, the usual git reset or git checkout will wipe the unsaved work. A frequent, explicit commit is one way to avoid the loss, but it clutters history and may not be desirable for experimental changes.
PhpStorm offers a built‑in safety net that tracks every file modification independently of any VCS. It is called Local History and can recover code that was never committed.
How Local History Works
Local History records a snapshot of a file each time you save it. The IDE stores these snapshots in its own system folder, separate from the project’s source tree and any .git data. The default retention period is about five working days, but the value can be changed in the IDE settings.
Key points:
- Granularity: snapshots are taken on every save, so you can see changes minute‑by‑minute.
- Scope: it works for all files, even those not under VCS control.
- Storage: on Windows the path is
%APPDATA%\JetBrains\PhpStorm\system\localHistory; on macOS it is~/Library/Caches/JetBrains/PhpStorm/localHistory. The data is local to the machine and not shared. - Access: the history is only visible inside the IDE via the Project tool window or the
Help | Find Actionmenu.
Practical Example: Restoring a Deleted Validation Block
Suppose you’re refactoring a controller. You accidentally delete a block of validation code and then run a global search‑and‑replace that changes several variable names. You’ve saved the file twice, so Ctrl+Z can’t bring it back. Here’s how to recover the lost code with Local History.
- Open the History: In the Project tool window, right‑click the affected file and choose Local History > Show History. If the menu item is missing, press
Ctrl+Shift+A(orCmd+Shift+Aon macOS) and type “Local History” to locate it. - Browse Snapshots: The History pane lists timestamps on the left. Click a timestamp that predates the accidental delete. A side‑by‑side diff appears: the left pane shows the file as of that moment, the right pane shows the current file.
- Restore the Block: In the diff view, locate the missing validation block. Click the arrow icon next to the block in the left pane to copy that snippet into the current file. The snippet appears in the right pane, and the file is now back to a working state.
- Verify: Run your unit tests or start the application to confirm the restoration works. Commit the file once you’re satisfied.
All of the above steps require only the IDE; no external tools or commands are involved.
Trade‑offs and Practical Checks
While Local History is powerful, it is not a replacement for a proper VCS workflow:
- Local‑only: the data lives on the machine that generated it. If you switch to a new workstation or your hard drive fails, the history is lost.
- Retention window: snapshots older than the configured retention period are automatically purged. If you need to keep a change for more than a few days, commit it.
- No cross‑project sharing: you cannot push Local History to a remote repository or share it with teammates.
- IDE dependency: the feature is accessible only through the JetBrains UI; there is no CLI or API for external scripts.
To check that Local History is working on your machine, try the following quick test:
- Create a new file in the Project view.
- Type a line, save, delete the line, and save again.
- Right‑click the file, choose Local History > Show History, and confirm that two distinct timestamps appear with a diff between them.
If the test fails, verify the retention setting under Settings | Appearance & Behavior | System Settings and ensure the IDE’s system folder has sufficient disk space.
Actionable Takeaway
Use Local History as a safety net for quick recovery of uncommitted work. Commit regularly for long‑term history and collaboration, but rely on the IDE’s snapshot feature when you need to undo a destructive change that happened between commits.
Remember: Local History is local, short‑term, and IDE‑only. Treat it as a complement to, not a substitute for, your VCS workflow.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.