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 in Visual Studio Code 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.
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.