基本上是这篇文章的翻译
这两天高频commit 提交信息越写越乱,到后来甚至开始上中文…
文章目录
规则1. commit subject和主体中间要有一个空行
commit subject也就是最开始的第一行,50个字以内对这次commit进行一个总结。如果后面还有内容要写的话,加一个空行,然后写详细内容。详细内容里可以加bullet list,连字符或者星号后加一个空格那种格式(详见下方示例)
Summarize changes in around 50 characters or less
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 the commit 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); various tools like `log`, `shortlog`
and `rebase` can get confused if you run the two together.
Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequences of this
change? Here's the place to explain them.
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
If you use an issue tracker, put references to them at the bottom,
like this:
Resolves: #123
See also: #456, #789
规则2. 将commit subject限制在50字以内
不是强制要求,但是可以让你思考。
如果做不到的话,就要反思你是不是commit太少了。应该对每个功能进行原子提交(atomic commit)。
规则3. 使用祈使句
祈使句(Imperative mood )意思是像给出命令一样。例如:
Clean your room
Close the door
Take out the trash
错误示例:
Fixed bug with Y
Changing behavior of X
更多例子:
If applied, this commit will refactor subsystem X for readability
If applied, this commit will update getting started documentation
If applied, this commit will remove deprecated methods
If applied, this commit will release version 1.0.0
If applied, this commit will merge pull request #123 from user/branch
规则4. 第一行首字母大写 & 不要加句号
规则5. 主体内容里面应该写what&why而不是how
Tips: 另一种格式&常用词
这个视频里的。视频我看了,除了这张截图其他的内容这篇文章里都有。
视频里建议的commit第一行的格式是
<type>[option scope]: <description>
- type就是fix、feat这些常用词
- scope是附加信息,例如哪个模块,用名词,可以不写
- description就是前面说的commit subject 总结性的一句话,不超过50字
- 后面的body、footer和规则1里面说的类似
例如:
fix[frontend]: window not render
两种格式都挺好的,感觉我自己写的时候会用第一种,和别人合作的时候会用第二种,并且丢出这篇文章(x