git commit 命令

git commit 命令 将暂存区内容添加到本地仓库中。

提交暂存区到本地仓库中:

git commit -m [message]

[message] 可以是一些备注信息。

提交暂存区的指定文件到仓库区:

$ git commit [file1] [file2] ... -m [message]

-a 参数设置修改文件后不需要执行 git add 命令,直接来提交

$ git commit -a

实例:

$ git add hello.php

$ git status -s
A  README
A  hello.php
$ git commit -m '第一次版本提交'
[master (root-commit) d32cf1f] 第一次版本提交
 2 files changed, 4 insertions(+)
 create mode 100644 README
 create mode 100644 hello.php

现在我们已经记录了快照。如果我们再执行 git status:

$ git status
# On branch master
nothing to commit (working directory clean)

以上输出说明我们在最近一次提交之后,没有做任何改动,是一个 "working directory clean",翻译过来就是干净的工作目录。