I accidentally deleted a piece of code on Visual Studio Code
. I haven’t closed visual studio yet.
CTRL + Z
doesn’t work. Edit + Undo
doesn’t work either. The variables are still stored.
It was accidental. I just happen to close a jupyter notebook box
Any idea how I can recover thank you?
3
Answers
There is a way to recover the deleted code if
CTRL +Z
doesn't work.You can click right on the
.ipynb
script, open chronology then go to your last changes and click on it. You will then see the deleted part.Cannot get it back if you have not backed up.
Good question, happens to most of us when working longer and not paying attention.
Vscode starting from a specific version does internal management of your code (March 2020 release). This feature is called
timeline
.What to do:
Right click on your .ipynb file
>Open Timeline
>Restore contents
on a specific version of your file.Also, before restoring, would suggest that you check out the version you’re going to restore by comparing it with the current one.
Note: This does not require the git repository to be active at the time of the incident. As this is what Vscode is technically doing by itself.