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



如果我想创建一个自定义 git commit template ,我可以将路径添加到模板为:

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

读取配置的读数还附加了默认模板。我知道它已注释了,但是无论如何要删除它,所以它仅显示我的自定义模板?

commit.status设置为false

git config commit.status false

git -c commit.status=false commit

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

默认情况下,您将拥有称为prepare-commit-msg.sample的GIT挂钩,它使您对可能的可能性有所了解。您可以通过重命名文件来激活它:

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

现在,如果您提交,则"默认模板"已消失。请注意,git挂钩存储在您的.git/hooks目录中,但您无法轻松将其推向遥控器。有关此主题的GIT书中有很多信息。

最新更新