这个输出在GIT中意味着什么

时间:2013-10-18 09:14:41

标签: git

我正在尝试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

这是什么意思?

1 个答案:

答案 0 :(得分: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
#