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
相關文章
相關標籤/搜索