Restore Deleted Files Using Local History
VS Code keeps a local history of your files, allowing you to recover deleted files or restore previous versions even if you haven't committed your changes to Git.
When to Use This
- You accidentally deleted a file that wasn't committed to Git.
- You made changes to a file but didn't commit them and want to go back to an earlier version.
- You closed a file after deleting it and need to recover its contents.
Steps to Restore a File
- Open the Command Palette (
Ctrl+Shift+P/Cmd+Shift+P). - Search for Local History: Find Entry to Restore.
- Type the name of the file you want to recover.
- Select the snapshot you want to restore. If the file had multiple saves, you will see multiple snapshots to choose from.
- In the history view, click the checkmark icon (✓) on the right side of the snapshot entry to restore the file.