Git让我提交未分级的更改

时间:2014-03-17 14:28:02

标签: git

我一直在阅读关于Git的一些教程,每个人都说,在我提交之前需要添加跟踪文件。我可以使用git add <file>git commit -a <file>。然而,我可以使用git commit <file>省略-a开关,它仍然会提交我的更改。我只是想知道这是否是正常行为。我正在使用Ubuntu 12.10和git 1.7.10.4

1 个答案:

答案 0 :(得分:3)

您愿意输入文件的路径。为什么git要求之前添加它?

顺便说一句,在命令行中有一个doc,你可以通过输入git help commit来看到它是正常的:

DESCRIPTION
  Stores the current contents of the index in a new commit along with a log message from
  the user describing the changes.

  The content to be added can be specified in several ways:

         ... snip...

  3. by listing files as arguments to the commit command, in which case the commit will
     ignore changes staged in the index, and instead record the current content of the
     listed files (which must already be known to git);