a commit git 参数是什么意思_git commit 命令
git commit 命令
前面章節(jié)我們使用 git add 命令將內(nèi)容寫入暫存區(qū)。
git commit 命令將暫存區(qū)內(nèi)容添加到本地倉庫中。
提交暫存區(qū)到本地倉庫中:
git commit -m [message]
[message] 可以是一些備注信息。
提交暫存區(qū)的指定文件到倉庫區(qū):
$ git commit [file1] [file2] ... -m [message]
-a 參數(shù)設(shè)置修改文件后不需要執(zhí)行 git add 命令,直接來提交
$ git commit -a
設(shè)置提交代碼時(shí)的用戶信息
開始前我們需要先設(shè)置提交的用戶信息,包括用戶名和郵箱:
$ git config --global user.name 'runoob'
$ git config --global user.email test@runoob.com
如果去掉 --global 參數(shù)只對(duì)當(dāng)前倉庫有效。
提交修改
接下來我們就可以對(duì) hello.php 的所有改動(dòng)從暫存區(qū)內(nèi)容添加到本地倉庫中。
以下實(shí)例,我們使用 -m 選項(xiàng)以在命令行中提供提交注釋。
$ 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
現(xiàn)在我們已經(jīng)記錄了快照。如果我們?cè)賵?zhí)行 git status:
$ git status
# On branch master
nothing to commit (working directory clean)
以上輸出說明我們?cè)谧罱淮翁峤恢?#xff0c;沒有做任何改動(dòng),是一個(gè) "working directory clean",翻譯過來就是干凈的工作目錄。
如果你沒有設(shè)置 -m 選項(xiàng),Git 會(huì)嘗試為你打開一個(gè)編輯器以填寫提交信息。 如果 Git 在你對(duì)它的配置中找不到相關(guān)信息,默認(rèn)會(huì)打開 vim。屏幕會(huì)像這樣:
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
# (use "git reset HEAD ..." to unstage)
#
# modified: hello.php
#
~
~
".git/COMMIT_EDITMSG" 9L, 257C
如果你覺得 git add 提交緩存的流程太過繁瑣,Git 也允許你用 -a 選項(xiàng)跳過這一步。命令格式如下:
git commit -a
我們先修改 hello.php 文件為以下內(nèi)容:
echo '菜鳥教程:www.runoob.com';
echo '菜鳥教程:www.runoob.com';
?>
再執(zhí)行以下命令:
$ git commit -am '修改 hello.php 文件'
[master 71ee2cb] 修改 hello.php 文件
1 file changed, 1 insertion(+)
總結(jié)
以上是生活随笔為你收集整理的a commit git 参数是什么意思_git commit 命令的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: generate报错 make_如何安装
- 下一篇: 1977标准_超过8分,就是痛风!附痛风