Commit message 书写指南#

Note

  • 该指南中的规则不一定适用于除 MegEngine 文档以外的项目。

  • 大部分情况下允许使用精简写法的 Commit Message.

标准写法#

一般而言,每个 commit 都有对应至少一个 Issue/Pull Request 与之相关联。

标准的 commit message 包含 Header、Body 和 Footer 三个部分(彼此之间空一行):

<type>(<scope>): <short summary>
// 空一行
<body>
// 空一行
<footer>

模版如下:

type(scope): 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

参考样例: 33aaf43

Body#

当需要对 commit 进行更加详细的描述时,通常会将其放在正文部分。 更常见的情况是,在 Issue/Pull Request 中进行具体的讨论和更改, 仅在有必要的情况下,会选择在 commit message 中说明原因和影响。

精简写法#

当 Commit message 中不包含 Body 部分时,可进行精简表示:

docs(tutorial): correct the xxx typo (#123)

其中 # 后跟着的数字是对应的 Issue/Pull Request ID.