git commit message 规范¶
在 Git 中,提交信息的规范非常重要,因为它可以帮助其他开发者了解每次提交的目的。以下是一种常见的提交信息规范:
-
type
: 提交的类型,例如:feat(新功能)、fix(修复 bug)、docs(文档改变)、style(格式或者结构改变)、refactor(代码重构)、test(测试代码)、chore(构建过程或辅助工具的变动)。 -
scope
: 表示影响的范围,例如:数据层、控制层、视图层等。 -
subject
: 提交的简短描述。 -
body
: 提交的详细描述,可以分为多行。 -
footer
: 关联的问题编号,例如: #123 , #456 。
以下是一个示例:
feat(user): add login function
This commit adds a new login function to the user module. The function takes a username and password and checks them against the database.
Related to #123, #456
在命令行中,你可以使用以下命令进行提交:
git commit -m "feat(user): add login function" -m "This commit adds a new login function to the user module. The function takes a username and password and checks them against the database." -m "Related to #123, #456"
这种规范可以帮助你和你的团队更好地理解每次提交的目的和影响。