如何使用 Notepad++ 在 git 提交消息中将标题与 body 分开?

How to separate title from body in a git commit message using Notepad++?

我在 windows 上使用 git,当我在命令提示符下使用 commit 命令时,我的 Notepad++ 打开并要求我输入如下提交消息:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Your branch is up-to-date with 'origin/master'.

这很好,但我希望能够将消息标题与其 body 分开。当我在 # 上面写我的提交消息时,它就像我使用 commit -m 命令一样发送,也就是说,它只包含一个标题。

有人可以建议使用 Notepad++ 将提交消息中的标题与 body 分开的正确方法吗?

Edit:这个问题不同于其他关于在提交消息中将 body 与标题分开的问题,因为其他问题询问如何从命令行进行,而我问如何使用 Notepad++ .

为了将标题与body分开,然后在一行中写下您的提交消息标题,然后按回车键,然后在下一行写下提交的简短描述,它将自动与标题分开,然后保存并推 git commit -m 将是标题使用记事本进行描述。

# 将被视为提交,不会出现在提交消息中。

您只需要添加您的标题+body,用两个换行符分隔,如下所示:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Your branch is up-to-date with 'origin/master'.
Title of the commit message

Body of the commit message (description)

然后在记事本++中按'save'并关闭window。

主题和正文由主题后的第一个空行分隔。因此,您有多种选择来编写具有主题和正文的消息。

git commit -m 'foo

bar'

git commit -m 'foo' -m 'bar'

或 在编辑器中,

foo

bar
#comment...
#comment...
#comment...