简体   繁体   English

在代码管理菜单中恢复visual studio code中删除的文件

[英]Restore deleted files in visual studio code in the code management menu

I am really devastated because I have accidentally deleted 3 of my files in Visual Studio Code.我真的很伤心,因为我在 Visual Studio Code 中不小心删除了 3 个文件。 I did it through the Source Code Management menu on the left side.我是通过左侧的“源代码管理”菜单完成的。 Now my question... Is there any possibility to restore the 3 files I deleted like this?现在我的问题...是否有可能恢复我这样删除的 3 个文件? I would appreciate any answer and maybe you want to know: I use Windows:-( I tried to look into the recycle bin of windows but it isn't there. :-(我将不胜感激任何答案,也许您想知道:我使用 Windows:-( 我试图查看 Windows 的回收站,但它不在那里。:-(

No, you cannot recover those files using VS Code or standard tools. 不,您无法使用VS Code或标准工具恢复这些文件。 They aren't put in the recycling bin (or your operating system's equivalent), they are removed using git clean or git reset --hard . 它们没有放入回收站(或您的操作系统的等效物),它们是使用git cleangit reset --hard删除的。 Condolences :-( 哀悼:-(

There are of course utilities for recovering deleted files that may or may not be successful, but that is outside the scope of this question. 当然有用于恢复已删除文件的实用程序可能成功也可能不成功,但这超出了本问题的范围。

I accidentally removed a file that wasn't even checked in to git. 我不小心删除了一个甚至没有签入git的文件。 Google brought me here. 谷歌把我带到了这里。 The file wasn't in the Trash can either (Ubuntu 18.4 VS Code 1.31.1). 该文件不在垃圾桶中(Ubuntu 18.4 VS Code 1.31.1)。 Looking at the git output I can see that it used git clean -f to remove it by f orce). 望着混帐输出我可以看到它使用git clean -f通过删除它f奥尔塞)。

Fortunately the file was still in the editor. 幸运的是,该文件仍在编辑器中。 Just press Ctrl + P and type the file name. 只需按Ctrl + P并键入文件名即可。 It should show up in the list of files and if you open it, it says "FILE_NAME (deleted from disk)" on the tab. 它应该显示在文件列表中,如果您打开它,它会在选项卡上显示“FILE_NAME(从磁盘中删除)” Just copy/paste the content to where it should be. 只需将内容复制/粘贴到应该的位置即可。

vscode maintains a file-history using its latest TIMELINE view . vscode 使用其最新的 TIMELINE视图维护文件历史记录。

How to restore deleted git-untracked files in vscode:如何在 vscode 中恢复已删除的 git-untracked 文件:

Create the files with the same name at the same directory.在同一目录下创建同名文件。

Go to TIMELINE on the File Explorer.转到文件资源管理器上的时间线。

You can get the older versions of the files.您可以获得旧版本的文件。

if you accidently click the delete menu option right below rename, as long as you don't panic and like restart your computer or something you can open that directory in the file explorer on your computer如果你不小心点击了重命名正下方的删除菜单选项,只要你不慌张,喜欢重启你的电脑什么的,你可以在你电脑的文件资源管理器中打开那个目录

and right click.并右键单击。

there should be options there to undo delete or whatever else you did to the directory.那里应该有撤消删除或您对目录所做的任何其他操作的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM