1

git 提交信息书写规范

 2 years ago
source link: https://www.jianshu.com/p/3ffdcd35ce77
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

git 提交信息书写规范

0.4342021.05.21 09:49:09字数 315阅读 43

现在比较流行的方案是约定式提交规范Conventional Commits),它受到了Angular提交准则的启发,并在很大程度上以其为依据。
约定式提交规范是一种基于提交消息的轻量级约定。

要想规范git commit 提交,我们先要了解一下Commit Message格式。

规范包括三个部分:Header,Body 和 Footer

<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>

commit的信息要简短精炼, 切勿长篇大论。

type(必须) : commit 的类别推荐如下:

feat : 新功能

fix : 修复bug

docs : 更新文档

style : 不影响程序逻辑的代码修改(代码格式化,缩进等)

refactor : 某个已有功能重构(代码逻辑重构)

perf : 性能优化,体验优化

test : 增加测试逻辑(添加或者更新测试用例)

build : 修改项目构建程序(gomod,npm,composer等)

revert : 代码回滚

chore : 除以上之外的其他类型

scope(可选) : 用于说明 commit 影响的范围

例如:订单模块,支付模块,某全局中间件调整,新增依赖库等。

subject

本次代码变更的的简短描述,还是上面的话。简短精炼, 切勿长篇大论。

Body 和 Footer 这里不涉及,如果想了解详细询问百度即可。


另外如果团队的技术架构比较完善,会存在一些其他要求。例如subject里面添加一些特殊前缀,例如安全检测编号,代码检测编号等。

最终还是要根据实际情况,制定符合自己团队的规范。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK