Git commit 多行信息提交

git.png

git commit可接受多个消息标志(-m)来容许多行提交git

原文地址: https://www.stefanjudis.com/t...

原文做者:Stephan Schneidervim

在命令行上使用git时,您可能已经使用了消息标志(-m)。 它容许开发人员在调用git commit时内联定义提交消息。bash

git commit -m "my commit message"

我不是这种方法的最大支持者,由于我更喜欢在vim中编辑提交消息(我仅用于编写提交消息)。 它使我有机会仔细检查我提交的文件。ide

今天,我了解到 git commit 命令接受多个消息标志。 😲spa

事实证实,您能够屡次使用 -m 选项。 git文档包括如下段落:命令行

若是给出了多个-m选项,则它们的值被串联为单独的段落

若是运行如下命令code

git co -m "commit title" -m "commit description"

这能够实现多行提交。blog

Author: stefan judis 
Date:   Tue Jul 7 21:53:21 2020 +0200

    commit title

    commit description

 test.txt | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

您能够使用多个 -m 标志来建立“多行提交”,而我不得不认可,在某些状况下这可能很是方便。ip

编辑:一些人指出,经过打开引号,按Enter并再次关闭带引号的提交,能够实现相同的提交结构,包括标题和正文(多行)。开发

git commit -m "commit title
>
> commit description"
[master 2fe1ef8] commit title
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test-2.txt
相关文章
相关标签/搜索