commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Commit

提交

When to use

使用场景

  • The current work is ready to record in git
  • The diff is understood and intentionally scoped
  • 当前工作已准备好记录到git中
  • 差异内容已明确,且变更范围是预先规划的

Process

流程

  1. Inspect
    git status
    ,
    git diff
    , and
    git diff --cached
    .
  2. Read recent commit messages so the new commit fits the repo.
  3. If there is nothing worth committing, stop.
  4. Stage only the intended files. Never stage secrets.
  5. Use the user's message if provided. Otherwise write a Conventional Commit message:
    • Format:
      type(scope): subject
    • Common types:
      feat
      ,
      fix
      ,
      refactor
      ,
      test
      ,
      docs
      ,
      chore
    • Keep the subject short, specific, and in imperative mood
    • Use the body for why the change exists, important context, and migrations or follow-up work
    • Good examples:
      feat(auth): add GitHub OAuth login
      ,
      fix(api): handle empty embedding results
  6. Create the commit and report the hash and message.
  1. 查看
    git status
    git diff
    git diff --cached
  2. 阅读近期的提交信息,确保新提交符合仓库的风格。
  3. 如果没有值得提交的内容,停止操作。
  4. 仅暂存目标文件,切勿暂存机密信息。
  5. 如果用户提供了提交信息则使用该信息。否则编写符合Conventional Commit规范的提交信息:
    • 格式:
      type(scope): subject
    • 常见类型:
      feat
      fix
      refactor
      test
      docs
      chore
    • 主题部分要简短、具体,且使用祈使语气
    • 正文部分说明变更的原因、重要上下文,以及迁移或后续工作
    • 优秀示例:
      feat(auth): add GitHub OAuth login
      fix(api): handle empty embedding results
  6. 创建提交并返回提交哈希值和提交信息。

Verification

验证

  • The staged changes match the intended scope
  • The commit exists
  • git status
    confirms the expected result
  • 暂存的变更与预期范围一致
  • 提交已成功创建
  • git status
    确认结果符合预期

Rules

规则

  • If the change breaks a contract or requires migration, note it clearly in the commit message body.
  • If there is nothing to commit or the diff is not understood, stop.
  • Prefer staging specific files over broad adds.
  • Do not commit
    .env
    , credentials, or keys.
  • The subject should say what changed. The body should explain why.
  • 如果变更破坏了约定或需要迁移,请在提交信息正文中明确说明。
  • 如果没有可提交的内容或无法理解差异,停止操作。
  • 优先暂存特定文件,而非大范围添加。
  • 不要提交
    .env
    文件、凭证或密钥。
  • 主题部分应说明变更内容,正文部分应解释变更原因。