git-commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit Commit
Git 提交消息
Generate concise and descriptive git commit messages based on staged code changes.
Analyze staged changes and recent commit history to generate a well-crafted commit message.
基于暂存的代码变更生成简洁且具有描述性的Git提交消息。
分析暂存变更和近期提交历史,生成规范的提交消息。
Commit Message Format
提交消息格式
<Subject>
<Description>Do not add unless explicitly instructed by the user.
Co-Authored-By<主题>
<描述>除非用户明确要求,否则不要添加字段。
Co-Authored-ByBest Practices
最佳实践
1. Capitalization and Punctuation
1. 大小写与标点
- Capitalize the first word of the subject line
- Do NOT end the subject line with punctuation
- 主题行首单词首字母大写
- 主题行末尾不要添加标点
2. Imperative Mood
2. 祈使语气
Use imperative mood in the subject line—give the tone of giving an order or request.
Good:
- Add fix for dark mode toggle state
- Update API authentication flow
- Remove deprecated database fields
Bad:
- Added fix for dark mode toggle state
- Updating API authentication flow
- Removing deprecated database fields
主题行使用祈使语气,即采用下达指令或请求的口吻。
规范示例:
- Add fix for dark mode toggle state
- Update API authentication flow
- Remove deprecated database fields
不规范示例:
- Added fix for dark mode toggle state
- Updating API authentication flow
- Removing deprecated database fields
3. Length Limits
3. 长度限制
- Subject line: Maximum 50 characters
- Body lines: Maximum 72 characters
- 主题行:最多50个字符
- 正文行:最多72个字符
4. Content Style
4. 内容风格
Be direct and concise. Eliminate filler words and phrases such as:
- "though"
- "maybe"
- "I think"
- "kind of"
- "just"
- "simply"
Think like a journalist—state what was done clearly and directly.
直接简洁,删除冗余词汇和短语,例如:
- "though"
- "maybe"
- "I think"
- "kind of"
- "just"
- "simply"
像记者一样思考——清晰直接地说明所做的变更。
Analysis Framework
分析框架
To craft thoughtful commit messages, consider:
- Why were these changes made?
- What effect do the changes have?
- Why was the change needed?
- What are the changes in reference to (issue numbers, PRs, tickets)?
为了编写高质量的提交消息,请考虑以下几点:
- 为什么要做这些变更?
- 这些变更会产生什么影响?
- 为什么需要这次变更?
- 这些变更涉及什么(问题编号、PR、工单)?
Examples
示例
Simple bug fix:
Fix authentication timeout
Increase session timeout from 30 to 60 minutes to prevent
frequent re-authentication for active users.
Fixes #123Feature addition:
Add dark mode support
Implement system-wide dark mode using CSS custom properties.
Users can toggle between light and dark themes via new
settings menu option.
Refs #456Refactoring:
Extract payment processing module
Move payment-related logic into dedicated module to improve
testability and reduce controller complexity.Breaking change:
Remove deprecated user endpoints
Delete /users/legacy endpoints which were marked for removal
in v2.0. Clients must use /v2/users endpoints instead.
BREAKING CHANGE: Migrate to v2 endpoints before upgrading简单Bug修复:
Fix authentication timeout
Increase session timeout from 30 to 60 minutes to prevent
frequent re-authentication for active users.
Fixes #123功能新增:
Add dark mode support
Implement system-wide dark mode using CSS custom properties.
Users can toggle between light and dark themes via new
settings menu option.
Refs #456代码重构:
Extract payment processing module
Move payment-related logic into dedicated module to improve
testability and reduce controller complexity.破坏性变更:
Remove deprecated user endpoints
Delete /users/legacy endpoints which were marked for removal
in v2.0. Clients must use /v2/users endpoints instead.
BREAKING CHANGE: Migrate to v2 endpoints before upgradingWorkflow
工作流程
- Run to see staged changes
git status - Run to review the actual changes
git diff --staged - Run to understand recent commit message style
git log -5 --oneline - Analyze changes to understand the "why" and "what"
- Draft the commit message following the format and practices above
- Verify: subject under 50 chars, imperative mood, no trailing punctuation
- 运行查看暂存变更
git status - 运行查看实际变更内容
git diff --staged - 运行了解近期提交消息风格
git log -5 --oneline - 分析变更以理解“原因”和“内容”
- 按照上述格式和最佳实践起草提交消息
- 验证:主题行不超过50字符、使用祈使语气、无末尾标点