Restore a deleted file in the Visual Studio Code Recycle Bin

Visual Studio-CodeRecycle Bin

Visual Studio-Code Problem Overview


Using Visual Studio Code Version 1.8.1 how do I restore a deleted file in the recycle bin?

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

It uses the normal trash bin of your system. So you can grab it our of there.

In Windows you find it in the explorer, in Linux it is as well in Konquerer / Nemo / ...

Solution 2 - Visual Studio-Code

  1. First go to Recycle Bin of your local machine.
  2. Your VS code deleted files is there in Recycle Bin.
  3. So, Right click on deleted files and select-> Restore option then your deleted files will be automatically restored in your VS code.

Solution 3 - Visual Studio-Code

If you just deleted the file, know that VSCode 1.52 (Dec. 2020) will support:

> ## Undo file operations in Explorer

> Explorer now supports Undo and Redo for all file operations: delete, rename, copy, move, new file and new folder. > > Make sure the focus is in the Explorer and trigger the Undo or Redo commands and your last file operation will be undone or redone respectively.
Keep in mind that we have separate undo stacks for the editor and the explorer and we choose which one to undo based on focus. > > Explorer Undo -- https://media.githubusercontent.com/media/microsoft/vscode-docs/vnext/release-notes/images/1_52/explorer-undo.gif

Solution 4 - Visual Studio-Code

I know the OP says Recycle Bin. What I do though is recreate the file, especially if it's a single file. And when in the file, I just press CMD+Z (I'm on a Mac) and I get my file back.

  1. Recreate the file in the same directory from where it was deleted.
  2. CMD+Z inside of the newly created file.

Solution 5 - Visual Studio-Code

Running on Ubuntu 18.04, with VS code 1.51.0

My deleted files from VS Code are located at:

~/.local/share/Trash/files

Every deleted file have a corresponding .trashinfo file which contains details about where the file is deleted from and deletion date and these are located at:

~/.local/share/Trash/info

More info here.

To search for your deleted files:

find ~/.local/share/Trash/files -name your_file_name 

In case you deleted files form a mounted ntfs filesystem, they will be located at:

/path_to_mounted_fs/.Trash-$UID

You can get $UID by doing echo $UID in your terminal.

Hope my case helped!

Solution 6 - Visual Studio-Code

I accidentally discarded changes in the Source Control in VS Code, I just needed to reopen this file and press Ctrl-Z few times, glad that VS Code saves your changes like that.

Solution 7 - Visual Studio-Code

who still facing the problem on linux and didnt find it on trash try this solution

https://github.com/Microsoft/vscode/issues/32078#issuecomment-434393058

find / -name "delete_file_name"

Solution 8 - Visual Studio-Code

Click in empty space of VS Code's explorer (it's where you see files listed vertically) and press undo Ctrl + z

It'll recover your permanently deleted files too.

VS Code is a lifesaver. ✌

Solution 9 - Visual Studio-Code

Just look up the files you deleted, inside Recycle Bin. Right click on it and do restore as you do normally with other deleted files. It is similar as you do normally because VS code also uses normal trash of your system.

Solution 10 - Visual Studio-Code

While pushing a repository to Github through Vs Studio code I deleted whole folder and they were not available in Recycle bin also. Here is how I recovered those files. For Windows.

> The method is to restore the previous version of the Drive in which the deleted file existed

I had deleted files from G: drive, the below images are self explanatory

>Open properties menu of the drive

enter image description here

>In properties go to previous versions tab, >where you can find the previously stored versions of that drive along with date at time of backup >use open or click on restore to get the previous version of that drive.

enter image description here

> Note: Manipulations in the drive after restore point won't be available

Solution 11 - Visual Studio-Code

If your local directory has git initialized and you have not committed the changes that include the delete, you can use git checkout -f to throw away local changes.

Solution 12 - Visual Studio-Code

Yes, I know this question is about VS Code but I think I can help someone. I permanently deleted a file, and I tried all the tips wrote here with no success. So I had to recover the file from OS Linux following this

grep -a -C 500 -F 'Unique string in text file' /dev/sda

Solution 13 - Visual Studio-Code

I am not sure how I deleted a file in VS Code, and couldn't find it in recycle bin. Found the file using the History feature of File Explorer.

File Explorer Options

File Explorer File History

File History is on

Solution 14 - Visual Studio-Code

It was asked above if there is a way to disable the ability to delete a file you created with an undo (@rochasdv).

There is a new setting to disable undo for file operations:

Explorer: Enable Undo default is warn, confirmation dialog

You can also set it to disable so that your files/folders will not participate in undo operations.

You can alo set it to allow - the pre-new setting situation.

Currently, this new setting is in the Insiders Build v1.64 so it may be in Stable early February, 2022.

Solution 15 - Visual Studio-Code

If you completely delete any of the components in angular using visual code, you can restore it Go to Recycle Bin and restore the deleted component that will be restored in the project.

Solution 16 - Visual Studio-Code

I tried most of the options above but none worked.

What worked for me was clicking and highlighting the folder where the file was deleted from in vscode. Then while it is selected, hit CTRL + Z. This works on windows.

Hitting CTRL+Z whiteout highlighting that folder didn't work.

Solution 17 - Visual Studio-Code

A month recovery can be done in visual studio code 1 Right click on file and 2 click Open Timeline and 3 select file from timeline 4 the last time file saved by you 5 and your last change of the file is recovered

NOTE : Not only last but all the previously saved check points can be recoverd from vs code

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser2584621View Question on Stackoverflow
Solution 1 - Visual Studio-CodeManuel ManhartView Answer on Stackoverflow
Solution 2 - Visual Studio-CodeRavi MengarView Answer on Stackoverflow
Solution 3 - Visual Studio-CodeVonCView Answer on Stackoverflow
Solution 4 - Visual Studio-CodeflashView Answer on Stackoverflow
Solution 5 - Visual Studio-CodeYuanjing CaiView Answer on Stackoverflow
Solution 6 - Visual Studio-CodeEugene IhnatsyeuView Answer on Stackoverflow
Solution 7 - Visual Studio-CodeMuhammadView Answer on Stackoverflow
Solution 8 - Visual Studio-CodelockhrtView Answer on Stackoverflow
Solution 9 - Visual Studio-CodeJohnView Answer on Stackoverflow
Solution 10 - Visual Studio-CodeNIRANJAN S PATTANSHETTIView Answer on Stackoverflow
Solution 11 - Visual Studio-CodecoltdorseyView Answer on Stackoverflow
Solution 12 - Visual Studio-CodeRodney SalcedoView Answer on Stackoverflow
Solution 13 - Visual Studio-CodeChirag TanejaView Answer on Stackoverflow
Solution 14 - Visual Studio-CodeMarkView Answer on Stackoverflow
Solution 15 - Visual Studio-CodeNITHESHView Answer on Stackoverflow
Solution 16 - Visual Studio-CodeHenry ObiaraijeView Answer on Stackoverflow
Solution 17 - Visual Studio-CodeAshish GautamView Answer on Stackoverflow