提交变更(git commit)

当所有的变更都进入暂存区,就可以使用git commit进行提交了

$ git commit

执行这句话后,会弹出文本编辑区(自己配置的或默认的),文本编辑器可能会显示如下内容


# 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:
#   modified:   main.c
#

如果加上-v开关,会把更改的详细内容加入


# 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:
#   modified:   main.c
#
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
diff --git a/main.c b/main.c
index e69de29..a865187 100644
--- a/main.c
+++ b/main.c
@@ -0,0 +1 @@
+Modify the first line of main.c

这里你可以输入一些修改的被指。以#开头的是注释,在最终提交中会被忽略,当然你也可以取消注释作为备注的一部分。

如果在命令行里,可以直接通过-m开关加入备注

$ git commit -m "my first commit!"
[master 4be71fb] my first commit!
 1 file changed, 1 insertion(+)

输出中包括了和该提交本身相关的一些信息:提交到了那个分支(master),提交的SHA-1校验和是多少(4be71fb)、改动了多少个文件以及源文件新增和删除了多少行的统计信息。

开关

-a开关将会把所有更改提交到暂存区,然后提交
-m "提交备注"直接输入提交的备注

猜你喜欢

转载自www.cnblogs.com/velscode/p/10585013.html