[关闭]
@EricJing 2018-11-19T06:19:09.000000Z 字数 2028 阅读 466

Git Commit 规范

工作/规范


Message Structure

A commit messages consists of three distinct parts separated by a blank line: the title, an optional body and an optional footer. The layout looks like this:

  1. type: subject
  2. body
  3. footer

The title consists of the type of the message and subject.

The Type

The type is contained within the title and can be one of these types:

feat: a new feature
fix: a bug fix
docs: changes to documentation
style: formatting, missing semi colons, etc; no code change
refactor: refactoring production code
test: adding tests, refactoring test; no production code change
chore: updating build tasks, package manager configs, etc; no production code change

The Subject

Subjects should be no greater than 50 characters, should begin with a capital letter and do not end with a period.

Use an imperative tone to describe what a commit does, rather than what it did. For example, use change; not changed or changes.

The Body

Not all commits are complex enough to warrant a body, therefore it is optional and only used when a commit requires a bit of explanation and context. Use the body to explain the what and why of a commit, not the how.

When writing a body, the blank line between the title and the body is required and you should limit the length of each line to no more than 72 characters.

The footer is optional and is used to reference issue tracker IDs.

Example Commit Message

  1. feat: Summarize changes in around 50 characters or less
  2. More detailed explanatory text, if necessary. Wrap it to about 72
  3. characters or so. In some contexts, the first line is treated as the
  4. subject of the commit and the rest of the text as the body. The
  5. blank line separating the summary from the body is critical (unless
  6. you omit the body entirely); various tools like `log`, `shortlog`
  7. and `rebase` can get confused if you run the two together.
  8. Explain the problem that this commit is solving. Focus on why you
  9. are making this change as opposed to how (the code explains that).
  10. Are there side effects or other unintuitive consequenses of this
  11. change? Here's the place to explain them.
  12. Further paragraphs come after blank lines.
  13. - Bullet points are okay, too
  14. - Typically a hyphen or asterisk is used for the bullet, preceded
  15. by a single space, with blank lines in between, but conventions
  16. vary here
  17. If you use an issue tracker, put references to them at the bottom,
  18. like this:
  19. Resolves: #123
  20. See also: #456, #789

Udacity Nanodegree Style Guide

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注