git-commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git Commit Message Convention

Git 提交信息规范

Utilize this skill when writing Git commit messages to apply Conventional Commits rules and Gitmoji.
使用此技能编写Git commit信息,以遵循Conventional Commits规则并使用Gitmoji。

When to Use This Skill

何时使用该技能

Activate this skill in the following situations:
  • When committing code changes
  • When a commit message format is required
  • When you need to maintain a consistent commit history
在以下场景中启用此技能:
  • 提交代码变更时
  • 需要统一提交信息格式时
  • 需要保持提交历史一致性时

How to Write Commit Messages

如何编写提交信息

Step 1: Check Staged Changes

步骤1:检查暂存的变更

Check the staged changes using the
git diff --staged
command.
使用
git diff --staged
命令检查暂存的变更。

Step 2: Determine Commit Type

步骤2:确定提交类型

Select the appropriate type and Gitmoji for the changes:
GitmojiCodeTypeDescription
:sparkles:
feat
Add a new feature
🐛
:bug:
fix
Fix a bug
📝
:memo:
docs
Add or update documentation
🎨
:art:
style
Code formatting, structural improvement
♻️
:recycle:
refactor
Code refactoring
:white_check_mark:
test
Add or update test code
🔧
:wrench:
chore
Update build, config files, etc.
🚀
:rocket:
perf
Improve performance
🔖
:bookmark:
release
Version release
为变更选择合适的类型和Gitmoji:
Gitmoji代码类型描述
:sparkles:
feat
添加新功能
🐛
:bug:
fix
修复bug
📝
:memo:
docs
添加或更新文档
🎨
:art:
style
代码格式化、结构优化
♻️
:recycle:
refactor
代码重构
:white_check_mark:
test
添加或更新测试代码
🔧
:wrench:
chore
更新构建、配置文件等
🚀
:rocket:
perf
性能优化
🔖
:bookmark:
release
版本发布

Step 3: Compose the Message

步骤3:撰写提交信息

Compose the commit message in the following format:
text
<gitmoji> <type>(<scope>): <subject>

<body>

<footer>
Components:
  • Gitmoji (Required): An emoji that visually represents the purpose of the commit.
  • Type (Required): The category of change (feat, fix, docs, style, refactor, perf, test, chore, release).
  • Scope (Optional): The name of the affected module (e.g.,
    (api)
    ,
    (chat)
    ,
    (auth)
    ).
  • Subject (Required): A concise description of the changes.
    • Use the imperative present tense ("add", not "added").
    • Use a lowercase first letter.
    • No period at the end.
    • Keep it under 50 characters.
  • Body (Optional): Explanation of the motivation for the change and how it differs from previous behavior.
  • Footer (Optional): Issue tracking (
    Closes #123
    ) or recording Breaking Changes.
按照以下格式撰写提交信息:
text
<gitmoji> <type>(<scope>): <subject>

<body>

<footer>
组成部分:
  • Gitmoji(必填):直观体现提交目的的表情符号。
  • 类型(必填):变更的类别(feat、fix、docs、style、refactor、perf、test、chore、release)。
  • 范围(可选):受影响模块的名称(例如
    (api)
    (chat)
    (auth)
    )。
  • 主题(必填):变更的简洁描述。
    • 使用祈使语气的现在时(如"add"而非"added")。
    • 首字母小写。
    • 结尾无句号。
    • 长度控制在50字符以内。
  • 正文(可选):解释变更的动机以及与之前行为的差异。
  • 页脚(可选):问题追踪(如
    Closes #123
    )或记录破坏性变更。

Step 4: Example

步骤4:示例

text
✨ feat(auth): add password reset via email

- Implemented a new endpoint `/auth/request-password-reset` that sends a secure, time-limited token to the user's email.
- Added a corresponding service to handle token generation and email dispatch.

Closes #78
text
✨ feat(auth): add password reset via email

- Implemented a new endpoint `/auth/request-password-reset` that sends a secure, time-limited token to the user's email.
- Added a corresponding service to handle token generation and email dispatch.

Closes #78

Guidelines

指南

  • Language: Write commit messages in English.
  • Gitmoji Reference: https://gitmoji.dev/
  • Clarity: The Subject explains "what," and the Body explains "why."
  • Breaking Changes: Record them in the Footer with the
    BREAKING CHANGE:
    prefix.
  • 语言:提交信息使用英文撰写。
  • Gitmoji参考https://gitmoji.dev/
  • 清晰性:主题说明“做了什么”,正文说明“为什么这么做”。
  • 破坏性变更:在页脚中以
    BREAKING CHANGE:
    前缀记录。