【问题标题】:How to separate title from body in a git commit message using Notepad++?如何使用 Notepad++ 将 git 提交消息中的标题与正文分开?
【发布时间】:2017-07-28 14:51:15
【问题描述】:

我在 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'.

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

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

编辑:这个问题与其他关于在提交消息中将正文与标题分开的问题不同,因为其他问题询问如何从命令行进行操作,而我询问如何使用记事本++ .

【问题讨论】:

标签: git version-control notepad++ commit git-commit


【解决方案1】:

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

git commit -m 'foo

bar'

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

或 在编辑器中,

foo

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

【讨论】:

    【解决方案2】:

    您只需添加标题+正文,并用两个换行符分隔,如下所示:

    # 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)
    

    然后在记事本++中按“保存”并关闭窗口。

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        猜你喜欢
        • 2017-03-23
        • 1970-01-01
        • 1970-01-01
        • 2011-08-01
        • 2018-12-21
        • 1970-01-01
        • 1970-01-01
        • 2011-09-07
        • 2015-06-30
        相关资源
        最近更新 更多