在刚刚初始化的回购中恢复git rm-rf。

在刚刚初始化的回购中恢复git rm-rf。,git,Git,我所做的如下: $ git init $ git add . # bunch of unwanted files were also added $ vim .gitignore $ git rm -rf * $ git add . # but the files were actually deleted from the ./ folder. 现在目录中只有.gitignore模式文件。所有必要的文件都不见了 正如在这篇文章中提到的 git复位头还有路要走吗 我不确定是否应该运行此命令,因

我所做的如下:

$ git init
$ git add .
# bunch of unwanted files were also added
$ vim .gitignore
$ git rm -rf *
$ git add .
# but the files were actually deleted from the ./ folder.
现在目录中只有.gitignore模式文件。所有必要的文件都不见了

正如在这篇文章中提到的

git复位头
还有路要走吗

我不确定是否应该运行此命令,因为到目前为止我还没有进行任何提交。

运行
git fsck--lost-found

$ mkdir tt
$ cd tt
$ git init
Initialized empty Git repository in ...
$ echo I am foo > foo
$ echo I am bar > bar
$ git add .
$ git rm -rf *
rm 'bar'
rm 'foo'
$ git fsck --lost-found
notice: HEAD points to an unborn branch (master)
Checking object directories: 100% (256/256), done.
notice: No default references
dangling blob 2adbcadb36527b3048a96c5bad232f6c9e762524
dangling blob bea14010b78ced155c64da9a4c2b1a6b0831335e
$ ls .git/lost-found/other/
2adbcadb36527b3048a96c5bad232f6c9e762524
bea14010b78ced155c64da9a4c2b1a6b0831335e
$ cat .git/lost-found/other/2adbcadb36527b3048a96c5bad232f6c9e762524 
I am foo
文件名已消失,但所有内容都恢复为基于哈希ID的名称。

运行
git fsck--lost-found

$ mkdir tt
$ cd tt
$ git init
Initialized empty Git repository in ...
$ echo I am foo > foo
$ echo I am bar > bar
$ git add .
$ git rm -rf *
rm 'bar'
rm 'foo'
$ git fsck --lost-found
notice: HEAD points to an unborn branch (master)
Checking object directories: 100% (256/256), done.
notice: No default references
dangling blob 2adbcadb36527b3048a96c5bad232f6c9e762524
dangling blob bea14010b78ced155c64da9a4c2b1a6b0831335e
$ ls .git/lost-found/other/
2adbcadb36527b3048a96c5bad232f6c9e762524
bea14010b78ced155c64da9a4c2b1a6b0831335e
$ cat .git/lost-found/other/2adbcadb36527b3048a96c5bad232f6c9e762524 
I am foo

文件名已消失,但所有内容都已恢复,他们的基于散列ID的名称。

git reset HEAD
表示未知版本
git log
以查看您初始化提交SHA,然后
git签出
git log
==>
致命:您当前的分支“master”还没有任何提交
git reset HEAD
表示未知版本
git log
以查看您先初始化提交SHA,然后
git签出
git日志
==>
致命:您当前的分支“主机”还没有任何提交
无需重新启动一周的工作。:)成功了。我查看了.git目录中的文件,但是失物招领只出现在
git fsck
命令之后。是的-在此之前,这些“悬空blob”位于.git/objects/目录中,并且处于压缩状态,Git-ified表单。在尝试了各种linux“取消删除”工具之后,这是我唯一可行且有效的解决方案。无需重新开始一周的工作。:)成功了。我查看了.git目录中的文件,但是失物招领只出现在
git fsck
命令之后。是的-在那之前,这些“悬空的blob”位于.git/objects/目录中,并且是压缩的、git化的形式。在尝试了各种linux“取消删除”工具之后,这是我唯一可行的、有效的解决方案。