commitizen(git commit format)

  • Install
    sudo npm install -g commitizen
    
    • first project config

      • config
      cd Path_Git_Porject
      # base config
       commitizen init cz-conventional-changelog --save --save-exact
       #  config with format check
       npm i -D husky @commitlint/config-conventional @commitlint/cli
      
      • if config with format check, need to config js and husky
        • create commitlint.config.js(with same path of package.json)
        echo 'module.exports = {extends: ["@commitlint/config-conventional"]};' > ./commitlint.config.js
        
        • husky(add package.json)
            ...,
         	"husky": {
         	 "hooks": {
         	 "commit-msg": "commitlint -e $GIT_PARAMS"
         		 }
         		}
        
    • second project config

    cd Path_Git_Porject
    commitizen init cz-conventional-changelog --force
    
    • use
    git cz relpace git commit
    
    • use by interactive mode
    1.Select the type of change that you're committing 选择改动类型 (<type>)
    
    2.What is the scope of this change (e.g. component or file name)? 填写改动范围 (<scope>)
    
    3.Write a short, imperative tense description of the change: 写一个精简的描述 (<subject>)
    
    4.Provide a longer description of the change: (press enter to skip) 对于改动写一段长描述 (<body>)
    
    5.Are there any breaking changes? (y/n) 是破坏性修改吗?默认n (<footer>)
    
    6.Does this change affect any openreve issues? (y/n) 改动修复了哪个问题?默认n (<footer>)
    
    • commit message format:husky will use commitlint check message format
    <type>(<scope>): <subject>
    <BLANK LINE>
    <body>
    <BLANK LINE>
    <footer>
    
  • Install ERROR or WARN
  • Fromat
    • type:必填项,用于指定commit的类型
      • feat:增加新功能 (主要type)
      • fix: 修复Bug (主要type)
      • docs:只改动了文档相关的内容 (特殊type)
      • style:不影响代码含义的改动,例如去掉空格、改变缩进、增删分号 (特殊type)
      • build:构造工具的或者外部依赖的改动,例如webpack,npm (特殊type)
      • refactor:代码重构时使用 (特殊type)
      • revert:执行git revert打印的message (特殊type)
    • scope:必填项,用于描述改动的范围,格式为项目名/模块名:如果一次commit修改多个模块,建议拆分成多次commit,以便更好追踪和维护
    • Body:详细描述,主要描述改动之前的情况及修改动机,对于小的修改不作要求,但是重大需求、更新等必须添加body来作说明
    • break changes:是否产生了破坏性修改,涉及break changes的改动必须指明该项,类似版本升级、接口参数减少、接口删除、迁移等
    • affect issues:是否影响了某个问题。例如我们使用jira时,我们在commit message中可以填写其影响的JIRA_ID,若要开启该功能需要先打通jira与gitlab
  • git config file
    • .gitconfig:the config of current user
      • Windows:C:\Users\administrator.gitconfig
      • Linux: ~/.gitconfig
    • .git:the config of current project
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值