简体   繁体   中英

What does this output mean in GIT

Well I was trying git reset command and i reached to the situation below where:

  • I have forthreset file in index as deleted
  • I have forthreset file as untracked.

So I added forthreset file using git add . then when I did git status I didn't find anything in index

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

What does this mean ?

Most likely you have removed and add same file in index (with same content). Consider:

> 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)

But, if you add another content (here: 222), it will be shown as changed file:

> 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
#

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM