2013-08-31 59 views
1

为什么git commit -am不适用于我的初始提交,但之后可用?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) 
$ 

回答

5

你必须首先git add你的文件,以回购。 git commit只提交对跟踪文件的更改,git commit -a将提交对跟踪文件的所有更改。但未跟踪的文件不会在任何时候提交。

你会发现即使在初始化后提交,如果你创建一个新文件,它将不会被提交到git commit -a,直到你git add它。

+0

+1谢谢你的非常有用的信息! – Anthony

相关问题