[英]Deleted all files in fresh repo with accidental git reset --hard
I was working on some code, which didn't have any kind of git repo set up. 我正在编写一些代码,没有设置任何git repo。 I ran:
我跑了:
git init
git remote add origin http://giturl.git
git init
git remote add origin http://giturl.git
then I ran git add -A
and realized I forgot to create a .gitignore
file. 然后我运行
git add -A
并意识到我忘记创建.gitignore
文件。
For some reason I ran git reset --hard
...oops, that was dumb. 由于某种原因,我运行了
git reset --hard
... oops,这真是愚蠢。
It deleted all the files in the folder, and I have no clue how, or if it's even possible to get them back. 它删除了文件夹中的所有文件,我不知道如何,或者是否有可能将它们取回。
Fortunately, I was saved by running git fsck --lost-found
. 幸运的是,我通过运行
git fsck --lost-found
得以保存。 Because I had at least ran git add -A
, I just had to sift through the blobs to get the data I needed back. 因为我至少运行过
git add -A
,所以我只需要筛选这些blob即可获得所需的数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.