git-commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git 代码提交

Git Code Commit

独立工具技能。谁调用都可以。何时提交、交哪些文件、提交信息要点由调用方给出;本技能只负责怎么提交。
This is an independent tool skill that can be called by any party. The caller specifies when to commit, which files to commit, and key points of the commit message; this skill only handles how to perform the commit.

目标

Objectives

按模式完成 Git 提交。交互模式可再问是否 push;auto 模式只做本地提交。
Complete Git commits according to the specified mode. In interactive mode, you can ask whether to push again; in auto mode, only local commits are performed.

模式

Modes

  • 交互(默认):用户显式要求提交或推送。
  • auto:调用方指定 auto。本地
    git add
    +
    git commit
    禁止 push,禁止问要不要推送。
  • Interactive (default): The user explicitly requests to commit or push.
  • auto: Specified by the caller. Perform local
    git add
    +
    git commit
    , push is prohibited, and do not ask whether to push.

统一工具定义

Unified Tool Definition

  • 交互式提问
    :大部分 Agent 都内置的一种工具, 由 Agent 向用户提出问题并提供选项和自定义输入的一种工具, 它在不同的 Agent 中的名称不同, 可能叫
    AskUserQuestion
    AskQuestion
    等。auto 模式不要用它问是否 push。
  • Interactive Questioning
    : A tool built into most Agents, which allows the Agent to ask the user questions and provide options and custom input. Its name may vary across different Agents, such as
    AskUserQuestion
    or
    AskQuestion
    . Do not use it to ask whether to push in auto mode.

交互模式

Interactive Mode

  1. 检查
    git status
    /
    git diff
    /
    git log
    ,理解变更意图。
  2. 判断是否包含密钥或不应提交的内容,使用
    交互式提问
    工具来向用户确认。
  3. 将变更组织成一个或多个逻辑提交,不要把无关变更塞进一个提交。
  4. 提交规范 写中文提交信息。
  5. 确认安全后
    git add
    git commit
    。不要
    --no-verify
  6. 使用
    交互式提问
    工具来问是否 push;需要才
    git push
  1. Check
    git status
    /
    git diff
    /
    git log
    to understand the intent of the changes.
  2. Determine if the changes contain keys or content that should not be committed, and use the
    Interactive Questioning
    tool to confirm with the user.
  3. Organize changes into one or more logical commits; do not include unrelated changes in a single commit.
  4. Write Chinese commit messages in accordance with the Commit Specification.
  5. After confirming safety, execute
    git add
    and
    git commit
    . Do not use
    --no-verify
    .
  6. Use the
    Interactive Questioning
    tool to ask whether to push; execute
    git push
    only if needed.

auto 模式

Auto Mode

  1. git status
    :没有已跟踪变更且没有应入库的新文件 → 汇报「无提交」,结束。
  2. 发现
    .env
    、密钥、凭证、明显不该入库的文件 → 停止,不要提交,列给用户。不要用提问把风险问过去。
  3. 暂存范围:调用方指定了路径则只暂存这些路径;未指定则只暂存本轮应入库文件。不要顺手塞进无关脏文件。不要强制 add 已被 gitignore 的路径。
  4. 一个逻辑提交;按 提交规范 写中文信息。调用方给了提交信息要点则采用,否则按实际 diff 写。
  5. git add
    指定路径 +
    git commit
    。不要
    --no-verify
    。不要
    git push
  6. 汇报 commit hash,并写明未推送。
  1. git status
    : If there are no tracked changes and no new files that should be added to the repository → Report "No commits" and end.
  2. If
    .env
    , keys, credentials, or files that clearly should not be added to the repository are found → Stop, do not commit, and list them for the user. Do not use questioning to transfer the risk to the user.
  3. Staging scope: If the caller specifies paths, only stage those paths; if not specified, only stage the files that should be added to the repository in this round. Do not include unrelated dirty files. Do not force add paths that are in gitignore.
  4. Create one logical commit; write Chinese messages in accordance with the Commit Specification. If the caller provides key points for the commit message, use them; otherwise, write based on the actual diff.
  5. Execute
    git add
    for the specified paths +
    git commit
    . Do not use
    --no-verify
    . Do not execute
    git push
    .
  6. Report the commit hash and indicate that it has not been pushed.

提交规范

Commit Specification

<类型>(<范围>)!: <描述>

[可选的正文]

[可选的脚注]
<Type>(<Scope>)!: <Description>

[Optional Body]

[Optional Footer]

核心规范

Core Specification

  • 必须使用中文编写提交信息
  • Commit messages must be written in Chinese

标题

Title

  • 使用祈使句或简洁动词短语
  • 描述“做了什么”,避免空泛描述
  • 尽量控制在 50 个字符以内
  • Use imperative sentences or concise verb phrases
  • Describe "what was done", avoid vague descriptions
  • Try to keep it within 50 characters

正文

Body

  • 解释为什么改,而不仅是改了什么
  • 说明重要实现取舍
  • 提及行为变化、兼容性影响、迁移事项
  • 每行尽量不超过 72 字符
  • Explain why the change was made, not just what was changed
  • Explain important implementation trade-offs
  • Mention behavioral changes, compatibility impacts, and migration matters
  • Try to keep each line within 72 characters

脚注

Footer

破坏性变更使用:
破坏性变更: <描述破坏性变更的内容>
For breaking changes, use:
破坏性变更: <描述破坏性变更的内容>

提交类型

Commit Types

类型说明
feat
新功能
fix
Bug 修复
docs
文档变更
style
代码格式变更,不影响逻辑
refactor
重构,不新增功能也不修复 bug
perf
性能优化
test
测试相关
build
构建系统或依赖变更
ci
CI/CD 配置变更
chore
日常维护,杂项
revert
撤销提交
TypeDescription
feat
New feature
fix
Bug fix
docs
Documentation changes
style
Code format changes, no impact on logic
refactor
Refactoring, no new features or bug fixes
perf
Performance optimization
test
Testing-related changes
build
Build system or dependency changes
ci
CI/CD configuration changes
chore
Daily maintenance, miscellaneous tasks
revert
Revert a commit