Git Commit Message Conventions: Types, Formats, and Examples
This article explains the widely used Git commit message convention, detailing the subject prefixes such as feat, fix, docs, and others, their meanings, example usages, and the benefits of adopting a standardized format for clearer project history and automation.
When browsing other developers' commit histories you often see prefixes like feat , fix , chore , etc.; this article demonstrates how to use a consistent commit message convention, using the element-plus/ant-design repository as an example.
This convention is not merely for show—it aims to improve the readability of commit logs and enable automated tooling to process them more effectively.
The basic format is subject: space message body , where the subject indicates the type of change.
1. feat: new feature
Example: feat: 增加用户注册功能
2. fix: bug fix
Example: fix: 修复登录页面崩溃的问题
3. docs: documentation changes
Example: docs: 更新README文件
4. style: code style changes (no functional impact)
Example: style: 删除多余的空行
5. refactor: code refactoring (neither new feature nor bug fix)
Example: refactor: 重构用户验证逻辑
6. perf: performance improvements
Example: perf: 优化图片加载速度
7. test: adding or updating tests
Example: test: 增加用户模块的单元测试
8. chore: miscellaneous tasks (build process or auxiliary tools)
Example: chore: 更新依赖库
9. build: changes to the build system or external dependencies
Example: build: 升级webpack到版本5
10. ci: continuous integration configuration changes
Example: ci: 修改GitHub Actions配置文件
11. revert: revert a previous commit
Example: revert: 回滚feat: 增加用户注册功能
Using a standardized commit message format makes a project more modular, easier to maintain and understand, and facilitates automated tools such as release scripts or changelog generators to parse and handle commit records.
Well‑written commit messages help team members and collaborators grasp the project's change history, thereby improving code maintenance efficiency and quality.
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.