使用commitizen管理提交

来源:互联网 发布:杭州网络推广红四 编辑:程序博客网 时间:2024/06/05 08:24
  • brew install node安装node.js
  • Install commitizen globally, if you have not already.
  • npm install -g commitizen(有可能会权限不足,可以使用sudo -i在mac上切换到root权限)
  • Install your preferred commitizen adapter globally, for example cz-conventional-changelog
    npm i -g cz-conventional-changelog
  • 在项目目录里,运行下面的命令,使其支持 Angular 的 Commit message 格式。
    commitizen init cz-conventional-changelog –save –save-exact –force

  • 但是存在一个问题 使用git commit -m hello依然可以提交
    可以使用钩子,在git使用提交命令时对命令进行拦截鉴别

  • 在git工程目录下执行如下命令,以安装钩子
    npm install ghooks –save-dev
  • 编写配置文件启用钩子

  • 使文件生效
    npm install taskmanager –save-dev

  • 如果使用git cz失败
    Create a .czrc file in your home directory, with path referring to the preferred, globally installed, commitizenadapter
    尝试执行 echo ‘{ “path”: “cz-conventional-changelog” }’ > ~/.czrc(来自于github源码https://github.com/commitizen/cz-cli)
0 0
原创粉丝点击