# git-commit-husky **Repository Path**: shouxinxin/git-commit-husky ## Basic Information - **Project Name**: git-commit-husky - **Description**: 用husky+commitlint规范团队的git提交信息 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-07-20 - **Last Updated**: 2021-07-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # git-commit-husky #### 介绍 用husky+commitlint规范团队的git提交信息。 #### 安装教程 1. 安装相关依赖包 ``` npm install husky -D npm install @commitlint/config-angular @commitlint/cli -D npm install commitizen -D npm install standard-version -D ``` 2. husky v6 以上配置 第 1 步: npx husky-init && npm install 第 2 步:修改已自动生成的 ./husky/pre-commit 钩子 ``` #!/bin/sh . "$(dirname "$0")/_/husky.sh" #npm run commit-msg npm run test ``` 第 3 步:创建 ./husky/commit-msg 钩子 npx husky add .husky/commit-msg "npm test" 并修改为 ``` #!/bin/sh . "$(dirname "$0")/_/husky.sh" npx --no-install commitlint --edit "$1" ``` #### 使用说明 1. 配置 commitlint 和 commitizen npx commitizen init cz-conventional-changelog --save-dev --save-exact 2. 更新 package.json 通过standard-version 自动生成 change log,并更新项目的版本信息添加 git tag, change log 中将收录所有 type 为 feat 和 fix 的 commit release: 自定义要发布的版本, 如: npm run release -- 1.0.0 release:major: 执行该脚本, 那么如果当前版本是 1.0.0 那么版本将被提升至 2.0.0 release:minor: 执行该脚本, 那么如果当前版本是 1.0.0 那么版本将被提升至 1.1.0 release:patch: 执行该脚本, 那么如果当前版本是 1.0.0 那么版本将被提升至 1.0.1 3. commit 方式 全局安装 commitizen 情况下可使用 git cz 或者 npm run commit 来提交代码 未全局安装 commitizen 情况下可使用 npm run commit 来提交代码 #### 参考链接 1. husky https://typicode.github.io/husky/#/?id=install #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request