How I Saved My Work Accidentally Discarded Using VSCode

Last updated on September 20, 2024 pm

Today, when I was dealing with my work progress, I accidentally discard all the files I wanted to commit, because part of the code was just compiled locally and didn’t need to submit.

At that moment, I really wanted to die, because this is the result of a day’s work.

Untitled.png

Life still goes on

Because all the files did not commit to git, git is certainly unable to help, so I’m checking the IDE to see if there‘s any black magic, I’ve discovered that VSCode has a powerful file history function. Interesting, this looks promising.

Firstly, I’m relieved to confirm that I already turned on the Local History in the settings, I remember this being the default setting, which I haven’t changed.

Jietu20240808-225408.jpg

The corresponding file path is in /Users/yourname/Library/Application\ Support/Code/User/History , after opening it includes a bunch of md5 named folders.

Untitled.png

For easier searching, it is recommended to use the list view and descending order by modification date,Open the first entries.json , I realized it records the relationship between the source file and all the historical files named by their hashes., I tried to recover the latest one.

Untitled.png

After saving and git diff,the file content is exactly what I discorded before,just based on this point alone, VSCode deserves the highest praise😎! It truly lives up to its reputation as the universal IDE.

Ending

Valuing my life, I choose to use 👑 vscode 👑


How I Saved My Work Accidentally Discarded Using VSCode
http://example.com/2024/08/08/How I Saved My Work Accidentally Discarded Using VSCode/
Author
Daniel Chan
Posted on
August 8, 2024
Licensed under