Recover Deleted Files in VSCode (Local)

VS Code’s Local History is a built-in feature that automatically saves snapshots of your files every time you save them. This is incredibly useful for recovering work that you might have accidentally deleted, even if you haven’t committed it to a source control system like Git.

Restoring Deleted Files

If you’ve deleted a file that wasn’t staged in Git, you can still get it back using Local History. Here’s how:

  1. Open the Command Palette (you can use the shortcut Ctrl+Shift+P on Windows/Linux or Cmd+Shift+P on macOS).
  2. Type “Local History: Find Entry to Restore” and select that option.
  3. You’ll see a list of all the files that have local history. You can search for your deleted file by name.
  4. Once you find the file, select it to see all the saved versions.
  5. Choose the version you want to restore and click the Restore Contents icon.

Even if you’ve already deleted the file from the Explorer, you can get it back. Just create a new, empty file with the exact same name, and the Timeline view will be populated with its local history.

Using the Timeline View

The Timeline view is another way to access your Local History. You can find it at the bottom of the File Explorer.

  • When you have a file open, the Timeline view will show you a history of all the saves for that file.
  • You can click on any entry in the timeline to see a diff, comparing that version with the previous one or with your current version.
  • Just like with the Command Palette, you can right-click on any entry and choose to Restore Contents.

This makes it easy to visualize the changes you’ve made over time and to jump back to a previous state of your file if you need to.

Ref: https://code.visualstudio.com/updates/v1_66#_local-history

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *

19 − 17 =