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

相关推荐
长沙红胖子Qt10 分钟前
SVN培训笔记(二):使用sourceTree通过git桥接管理svn项目
git·svn·sourcetree·sourcetree管理svn
半夏微凉半夏殇2 小时前
从多仓库到单仓库:如何高效迁移并统一管理多个Git项目
git
__万波__2 小时前
解决警告“..LF will be replaced by CRLF the next time Git touches it“
git
Software攻城狮2 小时前
git报错处理
git
明洞日记3 小时前
【软考每日一练015】计算机网络:DNS 递归查询与迭代查询解析
git·计算机网络·github
安河桥畔4 小时前
Git使用
大数据·git·elasticsearch
会跑步的蜗牛4 小时前
git相关问题(个人记录)
git
exm-zem4 小时前
Git 常用指令
git
映秀小子4 小时前
git设置命令缩写
git
Dream_sky分享4 小时前
IDEA 2025中git的Local Changes找不到
java·git·intellij-idea