• git commit message 规范


    1 Git提交描述格式规范解析

    一个规范的Git提交描述格式如下,包含Header, Body,Footer

    # Header
    [<type>](<scope>): <subject>
    
    # Body
    <body>
    
    # Footer
    <footer>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    1.1 Header

    Header头只有一行,包括3个字段: type(必需), scope(可选), subject(必需)

    属性描述
    type(必填)commit提交类型
    scope(选填)commint提交影响范围
    subject(必填)commint提交简短描述
    1.1.1 type 提交类型

    type说明提交类型:只允许使用下面属性

    属性描述
    feat新功能
    fix修改bug
    docs文档修改
    style格式修改
    refactor重构
    perf性能提升
    test测试
    build构建系统
    ci对CI配置文件修改
    chore修改构建流程、或者增加依赖库、工具
    revert回滚版本
    1.1.2 scope 作用范围

    scope说明提交影响范围:一般是修改的什么模块或者是什么功能,如【xx模块】/【xx功能】

    1.1.3 subject 提交主题

    subject 说明提交简短描述:一般是5-10个字简单描述做的任务,如【xx模块加入消息队列

    1.2 Body

    body说明提交详细描述:对于功能详细的描述,解释为什么加入这段代码,为什么调整优化等,如因分布式锁问题,导致死锁问题,优化调整xxxx

    1.3 Footer

    Footer脚包括2个字段: Breaking Changes、Closed Issues

    属性描述
    Breaking Changes中断性不兼容变动(不常用)
    Closed Issues关闭Issues问题
    1.3.1 Breaking Changes

    当前版本与之前版本不兼容,如迭代升级对之前版本不能做到兼容,就需要在Breaking Changes后面描述变动理由和迁移方法之类,此属性不常用

    1.3.2 Closed Issues

    当前 commit提交针对某个issue问题或者是bug编号等,如Closes # 234

    2 git commit 模板

    修改 ~/.gitconfig, 添加:

    [commit]
    template = ~/.gitmessage
    
    • 1
    • 2

    新建 ~/.gitmessage 内容可以如下:

    # head: [](): 
    # - type: feat, fix, docs, style, refactor, test, chore, perf, build, ci, revert
    # - scope: can be empty (eg. if the change is a global or difficult to assign to a single component)
    # - subject: start with verb (such as 'change'), 50-character line
    #
    # body: 72-character wrapped. This should answer:
    # * Why was this change necessary?
    # * How does it address the problem?
    # * Are there any side effects?
    #
    # footer: 
    # - Include a link to the ticket, if any.
    # - BREAKING CHANGE
    #
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    在有新的 commit 的时候,在 git add files 之后,git commit 会打开 commit 模板,在模板上修改即可。

    也可以进一步配置 commit message 检查等。

  • 相关阅读:
    [附源码]java毕业设计医院挂号管理系统
    appium+python自动化测试
    vue项目 (element-ui + vue-cropper) 创建一个实用的图片尺寸调整 角度调整 图片上传工具
    浮点数机制学习
    老掉牙的 synchronized 锁优化,一次给你讲清楚!
    第三方登录和第三方支付
    Spring Boot 事务详解
    IRQ中断服务函数
    最长公共子串问题
    【数据库数据恢复】SQL SERVER数据库MDF (NDF)或LDF损坏怎么恢复数据?
  • 原文地址:https://blog.csdn.net/qq_38342510/article/details/137174661