网络上很多关于 commit message 的想法都来源于 tpope,在他看来,一个好的 Git commit messge 应该是这样的:
Capitalized, short (50 chars or less) summary
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
如上:
- 首先是一个不超过 50 个字符的摘要(summary),单独占一行,首字母大写,行尾不要加点
.
。 - 如果有必要进行进一步解释,那么在摘要行下面空一行,添加描述信息。描述信息每行不超过 72 个字符。
commit message 应该使用祈使语气,也就是 “Fix bug”,而不是 “Fixed bug” 或者 “Fixes bug”。这是为了与 git