git-commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit 代码提交
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,禁止 push,禁止问要不要推送。git commit
- Interactive (default): The user explicitly requests to commit or push.
- auto: Specified by the caller. Perform local +
git add, push is prohibited, and do not ask whether to push.git commit
统一工具定义
Unified Tool Definition
- :大部分 Agent 都内置的一种工具, 由 Agent 向用户提出问题并提供选项和自定义输入的一种工具, 它在不同的 Agent 中的名称不同, 可能叫
交互式提问或AskUserQuestion等。auto 模式不要用它问是否 push。AskQuestion
- : 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
Interactive QuestioningorAskUserQuestion. Do not use it to ask whether to push in auto mode.AskQuestion
交互模式
Interactive Mode
- 检查 /
git status/git diff,理解变更意图。git log - 判断是否包含密钥或不应提交的内容,使用 工具来向用户确认。
交互式提问 - 将变更组织成一个或多个逻辑提交,不要把无关变更塞进一个提交。
- 按 提交规范 写中文提交信息。
- 确认安全后 和
git add。不要git commit。--no-verify - 使用 工具来问是否 push;需要才
交互式提问。git push
- Check /
git status/git diffto understand the intent of the changes.git log - Determine if the changes contain keys or content that should not be committed, and use the tool to confirm with the user.
Interactive Questioning - Organize changes into one or more logical commits; do not include unrelated changes in a single commit.
- Write Chinese commit messages in accordance with the Commit Specification.
- After confirming safety, execute and
git add. Do not usegit commit.--no-verify - Use the tool to ask whether to push; execute
Interactive Questioningonly if needed.git push
auto 模式
Auto Mode
- :没有已跟踪变更且没有应入库的新文件 → 汇报「无提交」,结束。
git status - 发现 、密钥、凭证、明显不该入库的文件 → 停止,不要提交,列给用户。不要用提问把风险问过去。
.env - 暂存范围:调用方指定了路径则只暂存这些路径;未指定则只暂存本轮应入库文件。不要顺手塞进无关脏文件。不要强制 add 已被 gitignore 的路径。
- 一个逻辑提交;按 提交规范 写中文信息。调用方给了提交信息要点则采用,否则按实际 diff 写。
- 指定路径 +
git add。不要git commit。不要--no-verify。git push - 汇报 commit hash,并写明未推送。
- : If there are no tracked changes and no new files that should be added to the repository → Report "No commits" and end.
git status - If , 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.
.env - 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.
- 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.
- Execute for the specified paths +
git add. Do not usegit commit. Do not execute--no-verify.git push - 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
| 类型 | 说明 |
|---|---|
| 新功能 |
| Bug 修复 |
| 文档变更 |
| 代码格式变更,不影响逻辑 |
| 重构,不新增功能也不修复 bug |
| 性能优化 |
| 测试相关 |
| 构建系统或依赖变更 |
| CI/CD 配置变更 |
| 日常维护,杂项 |
| 撤销提交 |
| Type | Description |
|---|---|
| New feature |
| Bug fix |
| Documentation changes |
| Code format changes, no impact on logic |
| Refactoring, no new features or bug fixes |
| Performance optimization |
| Testing-related changes |
| Build system or dependency changes |
| CI/CD configuration changes |
| Daily maintenance, miscellaneous tasks |
| Revert a commit |