visual-studio-coderecover

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?


Solution

  • 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.