Table of Contents
How to recover discarded changes in Visual Studio Code
A while ago in my first weekly update I already told you about the files I deleted by pressing the Discard All Changes in stead of the Stage All Changes button in Visual Studio Code. Yes, the GUI button…

It felt like my heart was being ripped out of my body. All the changes from the past few days were overwritten by older versions and even new files were remove from the stage.
And now you have the same problem… You probably looked for a way to recover these files from Visual Studio Code and came across an Extension.
I’m happy to tell you that Visual Studio Code has this option baked in as well.
Let’s recover files from the local history
Open Visual Studio Code and press CTRL + SHIFT + P simultaneously. This will open the Command Palette.
Type in Local History and select Local History: Find Entry to Restore.

A screen will open where you can see your recent (deleted) files.
You can scroll through the list and find the correct file.

After you select a file, you will be asked which version you want to open.
Select the correct version here.

After opening the version, a screen will open where the version will be compared with the version in your Workspace, or the file will be opened and displayed in its entirety.

And it is that easy! Success with it.
Disclaimer
Unfortunately I can’t find anything about this on the Visual Studio Code website. Also when searching for the commands nothing comes up.
This may only work because I have Git installed.
Unfortunately I can’t test it without Git, so I can’t say 100% that this always works.
Hi. Is there any other way to recover the files? I can’t see anything in my local history. Maybe because I restarted VS code. I have 10.000 untracked files (my whole laptop) in my source control in VS code. I think I messed up somehow initializing my Mac user account folder as a local Git repo. Then messed up further by selecting “discard all changes” of uncommitted untracked files and lost everything on my Mac. I was just trying to clean up resource control panel as it made vscode very slow. A lot of these file I don’t have a backup anywhere (Time Machine or ICloud or hard drive). Do you have an idea how to fix this? Much appreciated.
Thanks for the save <3
Thanks for the save <3