git提交管理

git提交管理

复制代码
scoop install nodejs
# windows
npm install --save-dev @commitlint/config-conventional @commitlint/cli
# non-windows
npm install --save-dev @commitlint/{cli,config-conventional}
# windows将commitlint.config.js修改为utf8编码, 默认utf16编码
echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
# 安装hook工具
npm install --save-dev husky
npx husky init
# Add commit message linting to commit-msg hook
echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg
# Windows users should use ` to escape dollar signs
echo "npx --no commitlint --edit `$1" > .husky/commit-msg

# Test simple usage
npx commitlint --from HEAD~1 --to HEAD --verbose

测试

一定会报错的git提交

复制代码
git commit -m "foo: this will fail"
#  husky > commit-msg
No staged files match any of provided globs.
⧗   input: foo: this will fail
✖   type must be one of [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test] [type-enum]

✖   found 1 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

husky - commit-msg script failed (code 1)

reference

相关推荐
李永奉5 小时前
Git和GitHub-用操作命令控制Git的工作区、暂存区、本地仓库之间状态的提交教程
git·github
羊在吃青草9 小时前
Git之远程仓库
git
凉、介16 小时前
Git 深入理解(二) | 常用命令
大数据·git·elasticsearch
xuxie991 天前
GIT版本管理
git
茶栀(*´I`*)1 天前
Git从零开始操作清单
git
李永奉2 天前
Git和GitHub-Git 管理的版本数据到底保存在哪个文件夹里?
git·github
Mortalbreeze2 天前
Git 基础篇(二):本地仓库管理与常用操作
git
武昌库里写JAVA4 天前
SpringBoot+Vue 项目介绍
java·javascript·git·sql·ai
Hvitur6 天前
Git - 多分支合并
git·github
考虑考虑6 天前
git刷新远程分支列表
git·后端·gitlab