Git moji

Git Commit Message 规范

Git Commit Message 虽然可以随意描述,但使用没有意义的描述对于后续 review 代码以及理解代码用途等方面都会造成巨大的影响。因此 Commit Message 具有意义是最基本的要求,此外,你还应该遵守一定的格式规范,这样能够让大家更快更清晰地了解该 Commit 的详情。这里我主要介绍下常规的 Git Commit 规范和 Gitmoji 规范,最后介绍下我常用的相关配置。

Commit Message 最基本的组成为:headerbodyfooter

1
2
3
4
5
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>

根据 conventional-commit-types, type 的可选值一般来说是有下面几种

  • feat: 添加新功能
  • fix: 修复 bug
  • docs: 仅对文档进行修改
  • style: 对代码语义无影响的格式修改(如去除无用空格、格式化等等修改)
  • refactor: 代码重构(既不是新增功能,也不是修改 bug 的代码变动)
  • perf: 提高性能的代码修改
  • test: 测试用例添加及修改
  • build: 影响构建系统或外部依赖关系的更改
  • ci: 更改 CI 配置文件和脚本
  • chore: 其它不涉及源码以及测试的修改

一般情况,commit 只会包含 header 部分。

Gitmoji 规范允许你在 Commit Message 中使用 Emoji ,简单的说,你可以用生动形象的 Emoji 来表示该次 Commit 的 type,Gitmoji 推荐的 header 格式是:

1
<gitmoji><type>: <subject>

常见的 moji 如下所示:

viewcodemeantranslate
🎨:art:Improve structure / format of the code.改良结构和代码格式
⚡️:zap:Improve performance.优化性能
🔥:fire:Remove code or files.移除代码或文件
🐛:bug:Fix a bug.修复 bug
🚑:ambulance:Critical hotfix.紧急的热修复
:sparkles:Introduce new features.引入新功能
📝:memo:Add or update documentation.添加或更新文档
🚀:rocket:Deploy stuff.部署
💄:lipstick:Add or update the UI and style files.添加或更新 UI 和样式文件
🎉:tada:Begin a project.开始一个全新的项目~
:white_check_mark:Add or update tests.添加或更新测试用例
🔒:lock:Fix security issues.修复安全问题
🔖:bookmark:Release / Version tags.发版 / 版本标签
🚨:rotating_light:Fix compiler / linter warnings.修复编译器或者 linter 的 warning
🚧:construction:Work in progress.工作在进行中
💚:green_heart:Fix CI Build.修复 CI 构建问题
⬇️:arrow_down:Downgrade dependencies.降级依赖库
⬆️:arrow_up:Upgrade dependencies.升级依赖库
📌:pushpin:Pin dependencies to specific versions.将依赖库固定到特定版本
👷:construction_worker:Add or update CI build system.添加或更新 CI 构建系统
📈:chart_with_upwards_trend:Add or update analytics or track code.添加或更新分析或跟踪代码
♻️:recycle:Refactor code.重构代码
:heavy_plus_sign:Add a dependency.添加一个依赖项
:heavy_minus_sign:Remove a dependency.删除一个依赖项
🔧:wrench:Add or update configuration files.添加或改变配置文件
🔨:hammer:Add or update development scripts.添加或更新构开发脚本
🌐:globe_with_meridians:Internationalization and localization.国际化和本地化(i18n)
✏️:pencil2:Fix typos.修复拼写错误
💩:poop:Write bad code that needs to be improved.当前代码尚需优化
:rewind:Revert changes.撤销之前的修改
🔀:twisted_rightwards_arrows:Merge branches.合并分支
📦:package:Add or update compiled files or packages.添加或更新编译的文件或包
👽:alien:Update code due to external API changes.由于外部 API 更改而更新代码
🚚:truck:Move or rename resources (e.g.: files, paths, routes).移动或重命名资源(诸如:文件、路径、路由)
📄:page_facing_up:Add or update license.添加或更新 LICENSE
💥:boom:Introduce breaking changes.引入不兼容的变动
🍱:bento:Add or update assets.添加或更新静态资源
♿️:wheelchair:Improve accessibility.提高可访问性
💡:bulb:Add or update comments in source code.在源代码中添加或更新注释
🍻:beers:Write code drunkenly.醉醺醺地编写代码
💬:speech_balloon:Add or update text and literals.添加或更新用于文本、对话框等文本字面量相关的更改
🗃:card_file_box:Perform database related changes.执行与数据库相关的更改
🔊:loud_sound:Add or update logs.添加或更新日志
🔇:mute:Remove logs.删除日志
👥:busts_in_silhouette:Add or update contributor(s).添加或更新贡献者
🚸:children_crossing:Improve user experience / usability.改善用户体验/可用性
🏗:building_construction:Make architectural changes.改变架构
📱:iphone:Work on responsive design.进行响应式设计
🤡:clown_face:Mock things.添加或更改 mock
🥚:egg:Add or update an easter egg.添加或更新彩蛋内容
🙈:see_no_evil:Add or update a .gitignore file.添加或更新 .gitignore 文件
📸:camera_flash:Add or updatesnapshots.添加或更新快照
⚗️:alembic:Perform experiments.实验性内容
🔍:mag:Improve SEO.提高 SEO
🏷:label:Add or update types.添加或更新类型声明
🌱:seedling:Add or update seed files.添加或更新种子文件
🚩:triangular_flag_on_post:Add, update, or remove feature flags.添加、更新或删除功能标志
🥅:goal_net:Catch errors.捕获错误
💫:dizzy:Add or update animations and transitions.添加或更新动画和过渡
🗑:wastebasket:Deprecate code that needs to be cleaned up.清理冗余代码
🛂:passport_control:Work on code related to authorization, roles and permissions.处理与授权、账户和权限相关的代码 |
🩹:adhesive_bandage:Simple fix for a non-critical issue.简单修复一个非关键问题
🧐:monocle_face:Data exploration/inspection.数据探索/检查
⚰️:coffin:Remove dead code.清除无效代码
🧪:test_tube:Add a failing test.添加一个运行失败的测试用例(TDD 第一步)
👔:necktie:Add or update business logic.添加或更新业务逻辑
🩺:stethoscope:Add or update healthcheck.添加或更新健康检查
🧱:bricks:Infrastructure related changes.基础设施相关改动
🧑‍💻:technologist:Improve developer experience.提升开发体验
🔐:closed_lock_with_key:Add or update secrets.添加或更新加密内容
💸:money_with_wings:Add sponsorships or money related infrastructure.添加赞助商或者资金支持相关内容
🧵:thread:Add or update code related to multithreading or concurrency.添加或更新多线程或与并发相关的代码
Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy