如何删除 git 提交默认模板消息?

How to remove git commit default template message?

如果我想创建自定义 git 提交模板,我可以将模板路径添加为:

[commit]
    template = ~/.gitmessage

但它一直附加在我的提交模板默认模板的底部:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
# modified:   lib/test.rb
#

阅读 configuration 他们还附加了默认模板。我知道它已被注释掉,但无论如何要删除它以便它只显示我的自定义模板?

commit.status 设置为 false

git config commit.status false

git -c commit.status=false commit

您可以使用 git 挂钩更改默认模板!

默认情况下,您将拥有这个名为 prepare-commit-msg.sample 的 git 挂钩,它让您对可能发生的事情有一些了解。您可以通过重命名文件来激活它:

 cp .git/hooks/prepare-commit-msg.sample .git/hooks/prepare-commit-msg

现在,如果您提交,'default template' 就会消失。请注意,git 挂钩存储在您的 .git/hooks 目录中,但您不能轻易将它们推送到远程。 Git Book 中有很多关于此主题的信息。