V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
ljzxloaf
V2EX  ›  git

你们写 commit message 有规范吗?

  •  
  •   ljzxloaf · 155 天前 · 6622 次点击
    这是一个创建于 155 天前的主题,其中的信息可能已经有所发展或是发生改变。
    如果有的话,有些怎样的规范?
    第 1 条附言  ·  155 天前
    大家会在 commit message 里加需求链接或者 bug 链接吗?像 jdk 或者 linuxkernel 那样?
    60 条回复    2023-11-26 23:53:45 +08:00
    zcf0508
        1
    zcf0508  
       155 天前 via Android
    cz
    hez2010
        2
    hez2010  
       155 天前
    wangwenfan
        3
    wangwenfan  
       155 天前   ❤️ 1
    模版大概是在这样的:
    <type>[optional scope]: <description>

    [optional body]
    [optional footer(s)]
    chesha1
        4
    chesha1  
       155 天前
    一般会加个开头吧 fix feat perf 之类的,但是这个好像也不是通行标准,有不少大厂的重要开源项目也不这么搞
    Altale
        5
    Altale  
       155 天前   ❤️ 1
    https://gist.github.com/ericavonb/3c79e5035567c8ef3267
    https://www.conventionalcommits.org/en/v1.0.0/#specification
    网上有很多,组里遵循不遵循与我无关,我都按照一定的风格写。
    zjp
        6
    zjp  
       155 天前 via Android   ❤️ 1
    约定式提交规范 https://www.conventionalcommits.org/zh-hans/v1.0.0/
    根据自己项目改改
    hez2010
        7
    hez2010  
       155 天前
    @chesha1 开头加 fix feat perf 其实主要是为了方便用工具自动生成 release note
    ljzxloaf
        8
    ljzxloaf  
    OP
       155 天前
    @hez2010 #2 好用吗
    pengtdyd
        9
    pengtdyd  
       155 天前
    有,用的是 angularjs 的规范。咦,我好像发现 angularjs 本身不怎么样,但是它搞的很多规范很实用。。。。
    AoEiuV020JP
        10
    AoEiuV020JP  
       155 天前
    没人管,我是尽量确保第一行简洁明了的写出改了什么,第二行空白,第三行看情况补充说明,

    HenryHE
        11
    HenryHE  
       155 天前
    有规范,毕竟每一个 commit 都是有原因的,所以会加上追踪信息。
    kosilence
        12
    kosilence  
       155 天前
    [ticket-number][which server] project name: what changed
    enchilada2020
        13
    enchilada2020  
       155 天前 via Android
    conventional commits+husky
    charmToby
        14
    charmToby  
       155 天前   ❤️ 1
    有的,一般会加上任务 ID 或者 bug ID
    dif
        15
    dif  
       155 天前
    用,和 angular 一样的规范。
    doco
        16
    doco  
       155 天前   ❤️ 1
    update, update xxx, update...
    jonty
        17
    jonty  
       155 天前
    新增/修复(范围):描述
    iovekkk
        18
    iovekkk  
       155 天前
    有,要标记一下是 bug 修复还是功能开发
    bug 修复要加上 bugid
    wu67
        19
    wu67  
       155 天前   ❤️ 1
    (fix|update|change|feat|remove): (模块-子模块-页面-组建). 功能描述内容巴拉巴拉. 如果有 issue 就再加上井号+id, 其他非同一平台的不管
    lshang
        20
    lshang  
       155 天前
    同 6 楼,conventional commit
    libook
        21
    libook  
       155 天前
    自己的项目绝大部分情况用 conventional commits ,别人的项目就 git log 看看过往提交风格,模仿着写,如果过往提交没有统一风格,就按照自己喜好写。

    这东西跟项目管理情况是息息相关的。
    比如开发一个本地特色的项目,也大可不必坚持用英文,只要能快速、准确、工整表达核心信息就可以了。
    再比如写的可能不是程序,而是个文档项目,只是想用 Git 来做版本控制,那么可以自己找或设计一套适合文档的提交风格。
    hugojtchen
        22
    hugojtchen  
       155 天前
    husky 做 git 钩子拦截
    commitlint 做校验信息
    git cz 填写内容
    leroy20317
        23
    leroy20317  
       155 天前
    commitlint + @commitlint/config-conventional
    Jony4Fun
        24
    Jony4Fun  
       155 天前
    <summary in 50 bytes>

    <description in 72 bytes per line>
    crazyTanuki
        25
    crazyTanuki  
       155 天前
    直接用哈士奇
    superchijinpeng
        26
    superchijinpeng  
       155 天前
    有规范,并且 commit message 也会链接 tapd
    churchill
        27
    churchill  
       155 天前
    规范不规范的我不知道,有的同学啊,提交倒是写了介绍,但点开一看,内容完全对不上
    咱不如每次都写“a bunch of code”,还省事
    ugu
        28
    ugu  
       155 天前
    angular 规范 用 commitlint 约束
    fpcxsun
        29
    fpcxsun  
       155 天前
    Description:
    TraceNo:
    recying5566
        30
    recying5566  
       155 天前
    @hez2010 这是什么编辑器?
    hez2010
        31
    hez2010  
       155 天前
    @recying5566 Visual Studio 2022 的 17.9 版本
    roycestevie6761
        32
    roycestevie6761  
       155 天前
    @hez2010 vs 越来越牛逼了
    noyidoit
        33
    noyidoit  
       155 天前
    @hez2010 https://imgur.com/a/oT6Ee8O 这两周 VSCode 直接把这个功能集成进 source control 了
    VikingX
        34
    VikingX  
       154 天前
    @noyidoit 是不是必须开通 GitHub Copilot?
    noyidoit
        35
    noyidoit  
       154 天前
    @VikingX 我原本以为是 Copilot 引入的,但你这么一说,我禁用插件测试了一下,发现是 "GitLens — Git supercharged v14.5.1",抱歉前面的信息造成了误解
    god
        36
    god  
       154 天前 via iPad
    ## https://github.com/Nutlope/aicommits
    aicommits --type conventional

    ## https://github.com/di-sukharev/opencommit
    oco

    ## https://github.com/zurawiki/gptcommit
    git commit -a

    ## https://github.com/appleboy/CodeGPT
    codegpt commit --preview --template_file your_file_path

    ## https://github.com/RomanHotsiy/commitgpt
    npx commitgpt
    levelworm
        37
    levelworm  
       154 天前 via Android
    我自己的规范:

    commit 加 jira link ,简单说明,长度不超过 GitHub 标题的长度(其实他的标题可以很长,但是 commit 的时候好像有个固定长度,超了就自动进入 description 了)。
    Conty
        38
    Conty  
       154 天前 via Android
    所有人不允许直接 git push 。用自己写的系统做 code review 。review 里面要写明白细节。
    netabare
        39
    netabare  
       154 天前 via Android   ❤️ 1
    不知道 commit message 里面塞表情符号算不算规范的一部分
    boomer995
        40
    boomer995  
       154 天前
    💥 feat(compiler): add 'comments' option
    🐛 fix(compiler): fix some bug
    📝 docs(compiler): add some docs
    🌷 UI(compiler): better styles
    🏰 chore(compiler): Made some changes to the scaffolding
    🌐 locale(compiler): Made a small contribution to internationalization
    qloog
        41
    qloog  
       154 天前
    要写的。方便日后 有 问题时查看 commit log , 如果是开源项目,便于日后自动生成 release note. 比如: https://github.com/go-eagle/eagle/releases
    dayeye2006199
        42
    dayeye2006199  
       154 天前
    没有,只要求交 PR 的时候 squash 成一个 commit ,然后信息需要有一定的描述性。
    你说 PR 太大,没法放一个 commit ,那要重新考虑这个 PR 的任务范围划分
    lazydog
        43
    lazydog  
       154 天前
    用 git 官方推荐的,但是我们组 99%的人胡逼写。
    VikingX
        44
    VikingX  
       154 天前
    @noyidoit 要用这个功能,是不是需要填入自己的 GPT APIKeys?还是说不需要额外购买 GPT 了?
    KratosOmega
        45
    KratosOmega  
       154 天前
    有的,还有 git hook 脚本自动检查,不符合规范不给 commit
    grumpyFish
        46
    grumpyFish  
       154 天前
    11.25......11.26........
    update
    fix
    bugfix
    jeesk
        47
    jeesk  
       154 天前
    zengguibo
        48
    zengguibo  
       154 天前
    带上任务或是 bug 的 ticket id ,这样就好管理一些
    Mocker1106
        49
    Mocker1106  
       154 天前
    mosanHZ
        50
    mosanHZ  
       154 天前
    看实际情况,假如你的 commit 除了你没人看,你怎么写都行,也没人会叼你
    a632079
        52
    a632079  
       154 天前
    用法的 conventional commitlint 。

    https://github.com/conventional-changelog/commitlint
    alanhe421
        53
    alanhe421  
       154 天前
    nodejsexpress
        54
    nodejsexpress  
       154 天前
    自己的 git 也会写一些关键词,起码以后看起来知道这里干了什么。
    Zchary
        55
    Zchary  
       154 天前
    feat: fix ** bug.
    Alliot
        56
    Alliot  
       153 天前
    noyidoit
        57
    noyidoit  
       153 天前
    @VikingX 就目前而言,这个功能不需要填入 APIKeys
    GeekGao
        58
    GeekGao  
       153 天前
    以前用 Fabricator 协作过,所以都是 fabricator 上的 comments
    810244966
        59
    810244966  
       153 天前
    跟着项目来,有些项目写的很细就写很细,有些新增功能就打个 1 ,修改就打个 fix ,我也跟着
    lslqtz
        60
    lslqtz  
       152 天前
    比较喜欢用 Module: Comment.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2863 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:53 · PVG 22:53 · LAX 07:53 · JFK 10:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.