天天看点

设置git commit 模板

from http://rachel.xplore.cn/read.php?304

git commit提交模板

设置git commit 模板

大 | 中 | 小

设置git commit 模板

[

设置git commit 模板

2012/02/28 10:58 | by rachel ] 上次说到git commit提交,如果你想把提交信息写得更详细,更规范,比如修复了什么BUG,BUG号是多少,借鉴了哪个文件,或其它更详细的描述等等,像下面这样的格式

subject

    Bug Fix [Y/N]:

    Bug ID:

    Scratch or Copy [S/C]:

    Copy from:

    Other Info:

但是你又不想那么麻烦每次提交都输入这些标识。我们可以设置一个提交模板。

编写一个commit.template文件,如上面内容,然后做如下操作

cp commit.template ~/.gitmessage

git config --global commit.template ~/.gitmessage

执行git config -l,可以看到多了一行commit.template=~/.gitmessage 的信息

那么提交代码时还是执行git commit

这时就会交互出现提交模板,照既定的格式填写必要的内容保存就可以了。