您的位置:首页 > 房产 > 家装 > Git commit规范

Git commit规范

2024/10/6 18:33:47 来源:https://blog.csdn.net/qq_34738754/article/details/139484882  浏览:    关键词:Git commit规范

1. Git commit规范

1.1. 格式

<type>(<scope>): <subject>

示例:

fix(ngRepeat): fix trackBy function being invoked with incorrect scope

1.2. type

主要的提交类型如下:

Type说明备注
feat提交新功能常用
fix修复bug常用
docs修改文档
style修改格式,例如格式化代码,空格,拼写错误等
refactor重构代码,没有添加新功能也没有修复bug
test添加或修改测试用例
perf代码性能调优
chore修改构建工具、构建流程、更新依赖库、文档生成逻辑例如vendor包

1.3. scope

表示此次commit涉及的文件范围,可以使用*来表示涉及多个范围。

1.4. subject

描述此次commit涉及的修改内容。

  • 使用祈使句(动词开头)、动宾短语。
  • 第一个字母不要大写。
  • 不要以.句号结尾。

2. Git commit工具

安装commitizencz-conventional-changelog

npm install -g commitizen cz-conventional-changelog
echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc

使用cz-cli

$ git cz
cz-cli@4.0.3, cz-conventional-changelog@3.0.1? Select the type of change that you're committing: (Use arrow keys)
❯ feat:     A new featurefix:      A bug fixdocs:     Documentation only changesstyle:    Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)refactor: A code change that neither fixes a bug nor adds a featureperf:     A code change that improves performancetest:     Adding missing tests or correcting existing tests
(Move up and down to reveal more choices)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com