git commit删除repo中的所有文件

时间:2012-04-11 05:27:08

标签: git

今天第二次git commit -m "don't quit me now"删除了我的整个回购。所以它是:

$ git add .
$ git commit -m "please, be gentle"

[master 7af0e9c] please, be gentle
140 files changed, 0 insertions(+), 3186 deletions(-)
delete mode 100644 .DS_Store
delete mode 100644 .gitignore
delete mode 100644 .rspec
delete mode 100644 Gemfile
...

我一直在使用Github for Mac和命令行,并想知道这是否会以某种方式使事情发生。

$ git checkout
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   deleted:    .DS_Store
#   deleted:    .gitignore
#   deleted:    .rspec
#   deleted:    Gemfile
#   deleted:    Gemfile.lock

1 个答案:

答案 0 :(得分:4)

由于git status告诉您所有内容都要暂停删除,因此在执行任何其他操作之前,请将索引重置为HEAD

git reset HEAD

执行此操作后,git status应回显

no changes added to commit (use "git add" and/or "git commit -a")

然后,再试一次:

git add .
git commit -m "new try"