当前位置: 首页 > news >正文

git commit日志规范

一、作用

编写格式化的 commit message 能够大大提高代码的维护效率。

比如:

  • 可以提供更多的历史信息,方便快速浏览;
  • 可以过滤某些 commit(比如文档改动),便于快速查找信息;
  • 可以直接从 commit 生成 Change log

二、Commit message 的格式

每次提交,Commit message 都包括三个部分:Message header,Message body 和 Message footer。

< type >(< scope >): < subject >    //header内容
// 空一行
< body >   //body内容
// 空一行
< footer >    //footer内容

其中,Header 是必需的,Body 和 Footer 可以省略。
不管是哪一个部分,任何一行都不得超过72个字符(或100个字符)。这是为了避免自动换行影响美观。

type

type 用于说明 commit 的类别。

  • feat A new feature
  • fix A bug fix
  • docs Documentation only changes
  • style Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor A code change that neither fixes a bug nor adds a feature
  • perf A code change that improves performance
  • test Adding missing tests or correcting existing tests
  • build Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore Other changes that don't modify src or test files
  • revert Reverts a previous commit

scope

scope 用于说明 commit 影响的范围,比如数据层、控制层、视图层、具体模块等等,视项目不同而不同。

subject

subject 是 commit 目的的简短描述,不超过50个字符。

body

Body 部分是对本次 commit 的详细描述,可以分成多行。

BREAKING CHANGE,用来描述当前 commit 与上一个版本不兼容的地方。
Issue,用来描述当前 commit 针对的某个issue。

三、举例

feat($browser): onUrlChange event (popstate/hashchange/polling)Added new event to $browser:
- forward popstate event if available
- forward hashchange event if popstate not available
- do polling when neither popstate nor hashchange availableBreaks $browser.onHashChange, which was removed (use onUrlChange instead)
fix($compile): couple of unit tests for IE9Older IEs serialize html uppercased, but IE9 does not...
Would be better to expect case insensitive, unfortunately jasmine does
not allow to user regexps for throw expectations.Closes #392
Breaks foo.bar api, foo.baz should be used instead
feat(directive): ng:disabled, ng:checked, ng:multiple, ng:readonly, ng:selectedNew directives for proper binding these attributes in older browsers (IE).
Added coresponding description, live examples and e2e tests.Closes #351
http://www.jsqmd.com/news/336178/

相关文章:

  • 2026年耐用的泾县PPR家装水管/红叶家装水管厂家热卖产品推荐(近期) - 行业平台推荐
  • 计算机网络经典问题透视:无线局域网名词中DCF和PCF的含义是什么?
  • 2026年比较好的贵州固化剂地坪漆/贵州丙烯酸地坪漆热门品牌厂家推荐 - 行业平台推荐
  • 嵌入式C++教程:std::span——轻量、非拥有的数组视图
  • 2026年口碑好的长春结构件机械加工/铝合金机械加工优质供应商推荐参考 - 行业平台推荐
  • 背包专题 - # Robberies
  • 2026鼻炎专业调理中心推荐:专业机构选择指南 - 品牌排行榜
  • 2026年比较好的马六甲生态板/实木生态板厂家推荐参考 - 行业平台推荐
  • 技术演进中的开发沉思-350:并发模型(上)
  • pg数据库
  • 《中医基础理论》- 2.哲学基础之藏象学说-肺系统详解 - 教程
  • 2026年耳鼻喉科专家有哪些?一文了解专业医师团队 - 品牌排行榜
  • Linux命令-logwatch (自动分析和汇总系统日志)
  • 2026鼻炎专业调理中心推荐:科学改善鼻腔健康 - 品牌排行榜
  • 08.08.01.tiptop webserver接口篇(制作接口:自定义发送接口)
  • 杰理之在对箱时红外按键处理【篇】
  • 我用 XinServer 重新定义了我的工作效率
  • 2026年固生堂和甘草医生哪个靠谱?中医服务综合对比 - 品牌排行榜
  • 08.07.01.tiptop webserver接口篇(环境搭建 搭建webserver服务器软件准备)
  • 杰理之单独调节系统叠加提示音音量方法【篇】
  • 阮岩看鼻炎怎样?2026年中医诊疗实践与见解 - 品牌排行榜
  • 2026年中医机构选择:固生堂中医是正规机构吗 - 品牌排行榜
  • 杰理之快速按遥控有时不灵敏修改方法【篇】
  • 08.07.02.tiptop webserver接口篇(创建webserver服务器)
  • 杰理之出现充电脚5V拔出后,耳机不会自动开机问题解决方法【篇】
  • 实测5个免费降ai率工具推荐,亲测把AI率降低到5%以下!2026届毕业生必看!降低ai率更轻松
  • 调理鼻炎效果好吗?2026年中医调理真实感受 - 品牌排行榜
  • 调理鼻炎怎样?2026年中医调理经验分享 - 品牌排行榜
  • 杰理之4)显示、播放设备名并在播放完提示音之后显示曲目【篇】
  • 2026年看鼻炎的专家有哪些?这些中医专家值得关注 - 品牌排行榜