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

相关推荐
Jeanyia8 小时前
GitLab 配套 Git 常用命令
git·gitlab
10mAh11 小时前
【Git】误删分支、reset --hard 后提交丢了怎么办?——reflog、fsck 与安全恢复实战
数据库·git·安全·回归
Lydro13 小时前
CentOS 7 安装高版本git
git·centos 7
guwentian1 天前
Git Worktree 实战:用并行多 Agent 把开发提速 N 倍
大数据·git·elasticsearch·wroktree
不吃鱼的羊1 天前
Git识别未修改的文件有修改
git
蓝黑墨水1 天前
一个git问题的处理
git
互联网中的一颗神经元1 天前
21 — 额外命令:同时开两个窗口、自动检查哨
git
_道隐_1 天前
git stash save 和 git stash push有什么区别?
git
_道隐_1 天前
git stash如何pop指定的stash change?
git
PC2005-cloud2 天前
Git学习笔记:GitHub Git Data API 完全指南,用 Go 操控 Git 底层对象
笔记·git·学习