Git commit.template

如果把此项指定为你系统上的一个文件,当你提交的时候, Git 会默认使用该文件定义的内容。 例如:你创建了一个模板文件$HOME/.gitmessage.txt,它看起来像这样:

[code]subject line

what happened

[ticket: X][/code]

设置commit.template,当运行git commit时, Git 会在你的编辑器中显示以上的内容, 设置commit.template如下:

$ git config --global commit.template $HOME/.gitmessage.txt $ git commit

然后当你提交时,在编辑器中显示的提交信息如下:

[code]subject line

what happened

[ticket: X]

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 …” to unstage)

modified: lib/test.rb

~
~
“.git/COMMIT_EDITMSG” 14L, 297C[/code]

如果你有特定的策略要运用在提交信息上,在系统上创建一个模板文件,设置 Git 默认使用它,这样当提交时,你的策略每次都会被运用。

REF:http://cwiki.ossez.com/pages/viewpage.action?pageId=7045548