Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recover a deleted (Jupyter Notebook) code in Visual Studio Code when CTRL + Z does not work?

I accidentally deleted a piece of code in Visual Studio Code. I haven't closed Visual Studio Code yet.

CTRL + Z doesn't work. Edit and 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 the deleted code?

like image 365
bravopapa Avatar asked Sep 07 '25 21:09

bravopapa


1 Answers

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.

like image 59
Warkaz Avatar answered Sep 09 '25 20:09

Warkaz