为什么git add -A添加删除

时间:2016-09-09 19:12:48

标签: git

我正在读一本书,在这里说:

git add命令有三种形式:

git add foo.txt添加名为foo.txt的文件 •git add .添加除已删除文件以外的所有新文件和已更改文件 •git add -A添加所有内容,包括删除

如果命令git add -A“添加删除似乎没有意义,”别担心。

您能举例说明“git add -A添加所有内容,包括删除”吗?

2 个答案:

答案 0 :(得分:0)

git add -a可能是您正在寻找的内容。

答案 1 :(得分:0)

在这里,举个例子。

$ git init
Initialized empty Git repository in /usr/local/google/home/depp/test/.git/
$ touch b
$ git add b
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#   new file:   b
#
$ rm b
$ git add -A
$ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)

您可以看到git add -A将删除添加到索引中。