0

好吧,我正在尝试git reset命令,但我遇到了以下情况:

  • 我在索引中的文件被删除了
  • 我有未跟踪的文件。

所以我添加了前重置文件,git add .然后当我这样做时,我git status没有在索引中找到任何东西

C:\Users\xxx\Desktop\learn>git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    forthreset
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       forthreset

C:\Users\xxx\Desktop\learn>git add forthreset

C:\Users\xxx\Desktop\learn>git status
# On branch master
nothing to commit, working directory clean

这是什么意思 ?

4

1 回答 1

1

很可能您已经在索引中删除并添加了相同的文件(具有相同的内容)。考虑:

> git init
Initialized empty Git repository in /tmp/t1/.git/
> echo 111 > a
> git add a
> git commit -m 1st
[master (root-commit) 89cc7c5] 1st
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a
> git rm a
rm 'a'
> git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    a
#
> echo 111 > a
> git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    a
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       a
> git add a
> git status
# On branch master
nothing to commit (working directory clean)

但是,如果您添加其他内容(此处:222),它将显示为更改的文件:

> git rm a
rm 'a'
> git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    a
#
> echo 222 > a
> git add a
> git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   a
#
于 2013-10-18T10:23:24.730 回答