Last month, a frontend expert joined our company and established some technical standards for our team. One of them concerned the standards for writing Commit Messages when submitting code to Git. At first, I thought it was unnecessary, but after looking at the Commit records of many large projects, I realized that this standard is essentially an industry norm.

First, let's take a look at the Commit Messages in my CodeStudy project:

Now let's look at the Commit Messages of the Vue framework, created by the renowned Evan You:

Indeed, a well-standardized Commit Message can really make a strong first impression, allowing people to quickly understand the content of the Commit and the functional modules involved. Next, let's discuss the benefits that standardized Commit Messages can bring.

Benefits of Standardization

  • Makes it easier for programmers to trace the commit history and understand what happened.
  • Once Commit Message conventions are enforced, it means that we will carefully make each commit. We can no longer put all kinds of changes into a single git commit, making the history of code changes much clearer.
  • Only formatted Commit Messages can be used to automatically generate a Change log.

Git Commit Conventions

<type>(<scope>): <subject>
<body>
<footer>
NamePurpose
typeSpecifies the category of the Git Commit; only the identifiers in the table below are allowed
scopeSpecifies the scope affected by the Commit, such as the data layer, control layer, or view layer
subjectA brief description of the purpose of the Commit, generally no more than 50 characters
bodyOptional; can span multiple lines; provides a detailed description, with a blank line between it and the header
footerOptional; generally used for breaking changes or closing issues, with a blank line between it and the body
TypeDescription
syncSynchronize bugs from the mainline or a branch
mergeMerge code
revertRoll back to the previous version
choreChanges to the build process or auxiliary tools
testAdd software tests
perfPerformance-related optimizations, such as improving performance or user experience
refactorRefactoring; code changes that are neither new features nor bug fixes
styleFormatting changes that do not affect code execution
docsWriting or updating documentation
fix / toFix bugs, whether discovered by QA or by the developers themselves
featNew features

Plugin Recommendation

The Commit Message Editor plugin is highly recommended for VS Code. It can quickly generate Git Commit Messages.