Git commit -am不适用于初始提交。为什么?

时间:2013-08-31 18:08:12

标签: git

为什么git commit -am在我的初始提交时不起作用,但之后有效?

$ touch test.txt
$ ls -a
.  ..  .git  test.txt
$ git commit -am "Initial commit"
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       test.txt
nothing added to commit but untracked files present (use "git add" to track)
$

1 个答案:

答案 0 :(得分:6)

您必须先将git add个文件发送到回购邮箱。 git commit仅提交对跟踪文件的更改,git commit -a将提交对跟踪文件的所有更改。但是,任何时候都不会提交未跟踪的文件。

你会发现,即使是在初始版之后的提交,如果你创建一个新文件,在git commit -a之前它将不会与git add一起提交。

相关问题