如何将项目特定信息添加到Git提交注释?

Tom*_*ris 5 git version-control

使用Git,如果您要提交,它会在提交消息下包含一个已注释掉的部分.其中包含有关编写提交消息的说明以及正在更改的文件列表.像这样:

# 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:  important-file.txt 
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   some-other-thing.txt
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       untracked.txt
Run Code Online (Sandbox Code Playgroud)

是否可以在此文件中添加更多材料?一个明确的用例是那些使用Trac,Redmine等问题跟踪软件的用户正在指定额外的语法元素.例如,Redmine用户可以包含问题编号和一些特殊关键字,以便将问题标记为已解决:关键字是"refs"(和"引用")和"修复"(或"关闭") - 但我经常发现它很难记住关键词.

那么,如果可以在提交指令的底部附加一些项目特定的文本,那将会很方便.

有没有现成的方法,或者我需要入侵吗?作为一个侧面问题,任何其他VCS(如Mercurial)是否有类似的行为?

Tom*_*ris 5

我用commit.template(如所描述的在这里).我可以使用prepare-commit-msg钩子,但是提交模板可以使工作稍微容易一些,而且我可以将提交模板保留在项目的版本控制中.