commit-message

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git Commit Message Generator

Git提交信息生成器

Generate concise, descriptive Git commit messages in English.
生成简洁、描述性的英文Git提交信息。

Process

流程

  1. Run
    git diff --cached
    (not
    git -C <path> diff --cached
    ) to check for staged changes
  2. If staged changes exist: generate commit message based on staged changes only
  3. If no staged changes: run
    git diff
    (not
    git -C <path> diff
    ) and
    git status
    (not
    git -C <path> status
    ) to view unstaged and untracked files
  4. For untracked files, intelligently assess which need content review (code/config files) vs which can be inferred from filename (assets, dependencies)
  5. Generate a single-line commit message (output ONLY the message, no follow-up questions)
  1. 运行
    git diff --cached
    (不要使用
    git -C <path> diff --cached
    )来检查暂存的变更
  2. 如果存在暂存变更:仅基于暂存变更生成提交信息
  3. 如果没有暂存变更:运行
    git diff
    (不要使用
    git -C <path> diff
    )和
    git status
    (不要使用
    git -C <path> status
    )来查看未暂存和未跟踪的文件
  4. 对于未跟踪的文件,智能评估哪些需要内容审查(代码/配置文件),哪些可以通过文件名推断(资源、依赖项)
  5. 生成单行提交信息(仅输出信息,不要后续问题)

Format

格式

  • Imperative mood, under 72 characters
  • Types:
    • Add: New features or files
    • Update: Enhancements to existing features
    • Remove: Delete files or features
    • Rename: Rename files or variables
    • Fix: Bug fixes
    • Improve: General improvements
    • Optimize: Performance improvements
    • Refactor: Code restructuring without behavior change
    • Document: Documentation updates
    • Test: Add or update tests
    • Chore: Maintenance tasks (deps, config, CI)
  • 祈使语气,不超过72个字符
  • 类型:
    • Add:新功能或文件
    • Update:现有功能的增强
    • Remove:删除文件或功能
    • Rename:重命名文件或变量
    • Fix:修复Bug
    • Improve:常规改进
    • Optimize:性能优化
    • Refactor:代码重构(不改变行为)
    • Document:文档更新
    • Test:添加或更新测试
    • Chore:维护任务(依赖项、配置、CI)

Handling Complex Changes

处理复杂变更

When multiple types of changes exist in a single commit:
  • Choose the type that represents the primary intent of the change
  • Priority order (when uncertain): Add > Fix > Update > Refactor > Chore
  • If truly mixed and unrelated, suggest the user split into separate commits
  • Describe the most significant change; omit minor ancillary modifications
当单次提交中存在多种类型的变更时:
  • 选择代表变更主要意图的类型
  • 优先级顺序(不确定时):Add > Fix > Update > Refactor > Chore
  • 如果确实是混合且不相关的变更,建议用户拆分为多个提交
  • 描述最重大的变更;省略次要的附属修改

Examples

示例

Add user authentication with JWT tokens
Update navbar to include search functionality
Remove deprecated API endpoints
Rename userService to UserAccountService
Fix null pointer exception in user service
Improve error handling in payment module
Optimize database queries for faster loading
Refactor user service to use repository pattern
Document API endpoints in README
Test payment processing edge cases
Chore: upgrade dependencies to latest versions
Add login page with validation and error handling
Fix authentication bug and update related tests
Add user authentication with JWT tokens
Update navbar to include search functionality
Remove deprecated API endpoints
Rename userService to UserAccountService
Fix null pointer exception in user service
Improve error handling in payment module
Optimize database queries for faster loading
Refactor user service to use repository pattern
Document API endpoints in README
Test payment processing edge cases
Chore: upgrade dependencies to latest versions
Add login page with validation and error handling
Fix authentication bug and update related tests