简体   繁体   English

git - 如何在 git rm -r.* 之后恢复已删除的子文件夹/文件

[英]git - how to recover deleted subfolders/file after git rm -r .*

I am using Windows working with a parentFolder that contain multiple subfolder .我正在使用parentFolder与包含多个subfolder的 parentFolder 一起使用。 I accidentally deleted all the subfolder with git rm -r.* right after I add those.add这些subfolder后,我不小心删除了所有带有git rm -r.*的子文件夹。 Here is more clear on what I did:这里更清楚我做了什么:

# Parent folder contain subfolder1, subfolder2, etc.
cd Parentfolder 
git init
git add .*
# Accidently delete all folder as followed
git rm -r .*

Now all of my subfolders are gone, I googled all types of recovery software but somehow could not recover the file.现在我所有的子文件夹都不见了,我用谷歌搜索了所有类型的恢复软件,但不知何故无法恢复文件。 Is there anyway I can recover this?无论如何我可以恢复这个吗?

If those files have been committed, then do (first save all the changes since after this operation all changes will be removed ):如果这些文件已提交,则执行(首先保存所有更改,因为在此操作之后所有更改都将被删除):

git add .
git reset --hard

If these were not committed edits, then you lost them.如果这些不是已提交的编辑,那么您将丢失它们。 If you use any IDE and made edits with it, then perhaps it has a means of undoing edits (like, for example, Local History in applications from JetBrains).如果您使用任何 IDE 并对其进行了编辑,那么它可能具有撤消编辑的方法(例如,JetBrains 应用程序中的本地历史记录)。

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

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