VUE git 约定规范 Commitizen 和 GIT HOOKS
对于git提交规范 来说,不同的团队可能会有不同的标准
我们要学习的commitizen就是其中的佼 佼者!commitizen仓库名为 ,它提供了个git cz的指令于代替git commit,简单句话介绍它: 当你使commitizen进代码提交(git commit)时,commitizen会提交你在提交时填写所有必需的提 交字段!这句话怎么解释呢?不着急,下我们就来安装并且使下commitizen,使完成之后你然就明 了这句话的意思!
全局安装把:
npm install -g commitizen@4.2.4
然后安装和配置 cz-customizable 插件
npm i cz-customizable@6.3.0 --save-dev
添加以下配置到 package.json 中

"config": { "commitizen":{ "path":"node_modules/cz-customizable" } }
然后项根录下创建.cz-config.js自定义提交内容

module.exports = { // 可选类型 types: [ { value: 'feat', name: 'feat: 新功能' }, { value: 'fix', name: 'fix: 修复' }, { value: 'docs', name: 'docs: 文档变更' }, { value: 'style', name: 'style: 代码格式(不影响代码运行的变动)' }, { value: 'refactor', name: 'refactor: 重构(既不是增加feature,也不是修复bug)' }, { value: 'perf', name: 'perf: 性能优化' }, { value: 'test', name: 'test: 增加测试' }, { value: 'chore', name: 'chore: 构建过程或辅助工具的变动' }, { value: 'revert', name: 'revert: 回退' }, { value: 'build', name: 'build: 打包' } ], // 消息步骤 messages: { type: '请选择提交类型:', customScope: '请输入修改范围(可选):', subject: '请简要描述提交(必填):', body: '请输入详细描述(可选):', footer: '请输入要关闭的issue(可选):', confirmCommit: '确认使用以上信息提交?(y/n/e/h)' }, // 跳过问题 skipQuestions: ['body', 'footer'], // subject文字长度默认是72 subjectLimit: 72 }
然后我们就可以尝试
git add .
git cz
我们 git cz 是代替了 git commit -m 'xxx'
他会问你一堆东西,其实就是你自己配置的。
写文不易,转载请注明出处:https://www.cnblogs.com/bi-hu/p/16335777.html
如果你忘记了用 git cz 提交咋个办? 解决方法来了:GITHOOKS:
git 钩子嘛。。。
阻止不合规的Git提交信息,那么就拦截报错。
主要用的就2个:
本文来自博客园,作者:咸瑜,转载请注明原文链接:https://www.cnblogs.com/bi-hu/p/16335777.html