git commit可承受多个音讯标记(-m)来容许多行提交

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

原文作者:Stephan Schneider

在命令行上应用git时,您可能曾经应用了音讯标记(-m)。 它容许开发人员在调用git commit时内联定义提交音讯。

git commit -m "my commit message"

我不是这种办法的最大支持者,因为我更喜爱在vim中编辑提交音讯(我仅用于编写提交音讯)。 它使我有机会仔细检查我提交的文件。

明天,我理解到 git commit 命令承受多个音讯标记。 ????

事实证明,您能够屡次应用 -m 选项。 git文档包含以下段落:

如果给出了多个-m选项,则它们的值被串联为独自的段落

如果运行以下命令

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

这能够实现多行提交。

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 标记来创立“多行提交”,而我不得不抵赖,在某些状况下这可能十分不便。

编辑:一些人指出,通过关上引号,按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