如果有的话,Git提交消息的推荐格式是什么?
当然,它会有所不同,但一个非常常见的格式看起来是这样的(摘自http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html,我认为它很好地总结了这个问题):
Short (50 chars or less) summary of changes
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.
Further paragraphs come after blank lines.
- Bullet points are okay, too
- Typically a hyphen or asterisk is used for the bullet, preceded by a
single space, with blank lines in between, but conventions vary here
有一件事情它没有提及到,那就是我自己采用的方法,即在第一行使用短标记来标识提交的类型。这些标记可能是 [fix]
表示修复bug,[new]
表示新功能,或者[dev]
仅影响内部的提交。采用这样的策略,可以轻松地从提交生成更改日志。
编辑: 这里还有另一个很好的总结,甚至来自于这个网站:在Git中,有哪些好的规范可用于格式化多个注释以单个提交
提交的差异描述了项目中的一个文本变化(语法变化),而提交的消息则描述了项目中的一个含义变化(语义变化)。
提交消息格式:
提交消息示例:
Percent-encode requests_mock URIs in API tests
Before, 32 API tests failed with the default .env file because it
contains the characters ‘<’ and ‘>’ (used as variable delimiters) which
are automatically percent-encoded in requests URIs (as those characters
are not allowed in URIs) but not in requests_mock URIs.
Now, all tests pass with the default .env file.
This does not percent-encode URIs in non-failing tests.
Add a company selection page in HTML templates
Before, users logged in to different accounts by entering different
credentials in the login page.
Now, users log in to different accounts by entering the same credentials
in the login page and selecting different companies in the company
selection page.
This does not allow logged in users to switch account without logging
out.
参考资料: