logo
📚 其他

Conventional Commits

Conventional Commits Cheat Sheet - 快速参考指南,收录常用语法、命令与实践。

📂 分类 · 其他🧭 Markdown 速查🏷️ 2 个标签
#git#commits
向下滚动查看内容
返回全部 Cheat Sheets

Getting Started

Quick Guide

Why Conventional Commits

  • Easy-to-follow structure for commit messages.
  • Clearly states the nature of changes.
  • Ensures uniformity in commit messages across teams.
  • Enables automated versioning and changelog generation.
  • Makes commit history easy to browse.
  • Allows the specification of 'scope' for more clarity.
  • Has a special notation for breaking changes.
  • Facilitates better understanding among team members.
  • Makes the review process efficient.
  • Helps in future troubleshooting with descriptive commit messages.

Structure

JAVASCRIPT
滚动查看更多
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

Official Website {.link-arrow}

Examples
  • feat: add jwt support
  • feat!: breaking change in API
  • feat(ui)!: redesign user profile page
  • fix: fix SQL injection vulnerability
  • fix(database): resolve data race condition
  • docs: update setup section of README
  • style(login): correct indentation in login component
  • refactor: refactor user database schema
  • perf: optimize user retrieval code for faster response
  • test: add tests for jwt authentication
  • test(payment): add tests for the payment gateway
  • chore: update build script
  • chore(deps): update dependencies
  • build(docker): update Dockerfile to use node 14
  • ci: add job for integration tests
  • revert: revert commit a1b2c3d4e5f
Types
TypeDescription
featIntroduces a new feature
fixFixes a bug
docsChanges in documentation only
styleCode changes that do not impact the functionality (e.g., formatting, white-space, etc)
refactorCode changes that neither fix a bug nor introduce a feature, typically improving code readability or structure
perfCode changes that improve performance
testAddition of missing tests or corrections to existing tests
choreChanges that do not modify the source code or test files, like tweaking the build process or adding dependencies
buildChanges affecting the build system or external dependencies (e.g., changes in webpack, npm packages)
ciChanges to Continuous Integration configuration files and scripts (e.g., Travis, CircleCI, Jenkins)
revertReverts a previously made commit

{.bold-first}

Specification

Specification
  • Commits MUST be prefixed with a type, which consists of a noun, feat, fix, etc., followed by the OPTIONAL scope, OPTIONAL !, and REQUIRED terminal colon and space.
  • The type feat MUST be used when a commit adds a new feature to your application or library.
  • The type fix MUST be used when a commit represents a bug fix for your application.
  • A scope MAY be provided after a type. A scope MUST consist of a noun describing a section of the codebase surrounded by parenthesis, e.g., fix(parser):
  • A description MUST immediately follow the colon and space after the type/scope prefix. The description is a short summary of the code changes, e.g., fix: array parsing issue when multiple spaces were contained in string.
  • A longer commit body MAY be provided after the short description, providing additional contextual information about the code changes. The body MUST begin one blank line after the description.
  • A commit body is free-form and MAY consist of any number of newline separated paragraphs.
  • One or more footers MAY be provided one blank line after the body. Each footer MUST consist of a word token, followed by either a :<space> or <space># separator, followed by a string value (this is inspired by the git trailer convention).
  • A footer’s token MUST use - in place of whitespace characters, e.g., Acked-by (this helps differentiate the footer section from a multi-paragraph body). An exception is made for BREAKING CHANGE, which MAY also be used as a token.
  • A footer’s value MAY contain spaces and newlines, and parsing MUST terminate when the next valid footer token/separator pair is observed.
  • Breaking changes MUST be indicated in the type/scope prefix of a commit, or as an entry in the footer.
  • If included as a footer, a breaking change MUST consist of the uppercase text BREAKING CHANGE, followed by a colon, space, and description, e.g., BREAKING CHANGE: environment variables now take precedence over config files.
  • If included in the type/scope prefix, breaking changes MUST be indicated by a ! immediately before the :. If ! is used, BREAKING CHANGE: MAY be omitted from the footer section, and the commit description SHALL be used to describe the breaking change.
  • Types other than feat and fix MAY be used in your commit messages, e.g., docs: update ref docs.
  • The units of information that make up Conventional Commits MUST NOT be treated as case sensitive by implementors, with the exception of BREAKING CHANGE which MUST be uppercase.
  • BREAKING-CHANGE MUST be synonymous with BREAKING CHANGE, when used as a token in a footer.

Also see

相关 Cheat Sheets

1v1免费职业咨询
logo

Follow Us

linkedinfacebooktwitterinstagramweiboyoutubebilibilitiktokxigua

We Accept

/image/layout/pay-paypal.png/image/layout/pay-visa.png/image/layout/pay-master-card.png/image/layout/pay-airwallex.png/image/layout/pay-alipay.png

地址

Level 10b, 144 Edward Street, Brisbane CBD(Headquarter)
Level 2, 171 La Trobe St, Melbourne VIC 3000
四川省成都市武侯区桂溪街道天府大道中段500号D5东方希望天祥广场B座45A13号
Business Hub, 155 Waymouth St, Adelaide SA 5000

Disclaimer

footer-disclaimerfooter-disclaimer

JR Academy acknowledges Traditional Owners of Country throughout Australia and recognises the continuing connection to lands, waters and communities. We pay our respect to Aboriginal and Torres Strait Islander cultures; and to Elders past and present. Aboriginal and Torres Strait Islander peoples should be aware that this website may contain images or names of people who have since passed away.

匠人学院网站上的所有内容,包括课程材料、徽标和匠人学院网站上提供的信息,均受澳大利亚政府知识产权法的保护。严禁未经授权使用、销售、分发、复制或修改。违规行为可能会导致法律诉讼。通过访问我们的网站,您同意尊重我们的知识产权。 JR Academy Pty Ltd 保留所有权利,包括专利、商标和版权。任何侵权行为都将受到法律追究。查看用户协议

© 2017-2025 JR Academy Pty Ltd. All rights reserved.

ABN 26621887572