git add→git commit。这是正确的吗?

时间:2016-12-30 23:18:44

标签: git

现在我正在制作Rails-tutorial practice3.1和3.2。

有些事情我不明白。

<solve first exercise>
    ★★★$ git commit -am "Eliminate repetition (solves exercise 3.1)"
<solve second exercise>
    $ git add -A
    $ git commit -m "Add a Contact page (solves exercise 3.2)"
    $ git push -u origin static-pages-exercises
    $ git checkout master

为什么没有&#34; git add&#34;在★★★?? 我想,

演员(worktree)

↓↑★git add

索引(临时区域)

↓↓★git commit

本地存储库

所以我们不能在没有git add的情况下提交, 但我们可以。

现在我刚刚测试了,

$ git commit -m "Add a Contact page (solves exercise 3.2)"

很糟糕。 (未提交更改的更改)

   $ git commit -am "Add a Contact page (solves exercise 3.2)"

没关系。 (添加联系页面(解决练习3.2)) ......为什么我们可以这个?

实际上,我不知道选项-a ....

的含义

请告诉我

1)我们可以在没有git add的情况下进行git提交吗?

2)git commit -a

的含义

感谢

1 个答案:

答案 0 :(得分:1)

-a标志允许您在与提交相同的命令中添加/暂存已更改的文件。因此,使用git commit -am "message"相当于git add -A,后跟git commit -m "message"

https://git-scm.com/docs/git-add

https://git-scm.com/docs/git-commit