commit-zh
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese中文 Git 提交
Chinese Git Commit
分析暂存/未暂存变更,生成中文 conventional commit message,主 agent 全程执行。
Analyze staged/unstaged changes and generate Chinese conventional commit messages, executed entirely by the main agent.
Conventional Commit 格式
Conventional Commit Format
<type>[(scope)]: <中文描述>
[可选正文]
[可选脚注]type/scope 始终英文,subject/body/footer 中文。
<type>[(scope)]: <Chinese description>
[Optional body]
[Optional footer]type/scope must always be in English, subject/body/footer in Chinese.
Commit Types
Commit Types
| Type | 用途 |
|---|---|
| 新功能 |
| 修复 bug |
| 文档变更 |
| 格式/样式 |
| 重构 |
| 性能优化 |
| 测试相关 |
| 构建系统/依赖 |
| CI/配置变更 |
| 维护/杂项 |
| 回退提交 |
| Type | Purpose |
|---|---|
| New feature |
| Bug fix |
| Documentation changes |
| Formatting/style changes |
| Code refactoring |
| Performance optimization |
| Testing-related changes |
| Build system/dependencies |
| CI/configuration changes |
| Maintenance/miscellaneous |
| Revert a previous commit |
工作流
Workflow
1. 检查仓库状态
1. Check Repository Status
bash
git status --porcelain无变更则停止。
bash
git status --porcelainStop if there are no changes.
2. 分析 Diff
2. Analyze Diff
bash
undefinedbash
undefined有暂存文件用暂存 diff
Use staged diff if there are staged files
git diff --staged
git diff --staged
无暂存用工作区 diff
Use workspace diff if no files are staged
git diff
undefinedgit diff
undefined3. 暂存文件(如需)
3. Stage Files (If Needed)
无暂存时按逻辑分组暂存:
bash
git add path/to/file1 path/to/file2- 按逻辑关联分组
- 禁止暂存可能含密钥的文件(.env、credentials、private keys)
- 禁止 /
git add .git add -A - 多逻辑单元 → 建议拆分多次提交
Stage files in logical groups when no files are staged:
bash
git add path/to/file1 path/to/file2- Group by logical relevance
- Prohibit staging files that may contain secrets (.env, credentials, private keys)
- Prohibit /
git add .git add -A - Multiple logical units → Suggest splitting into multiple commits
4. 生成 Commit Message
4. Generate Commit Message
- Type:变更类型(英文)
- Scope:目录/模块名(英文,可省略)
- Subject:中文摘要,祈使句式,≤72 字符
- Body:列表解释 why/what,≤3 条,每条 ≤72 字符
- - Footer:破坏性变更/issue 引用
- Type: Change type (English)
- Scope: Directory/module name (English, optional)
- Subject: Chinese summary, imperative mood, ≤72 characters
- Body: List with explaining why/what, ≤3 items, each ≤72 characters
- - Footer: Breaking changes/issue references
格式约束
Format Constraints
- Subject ≤72 字符,无句号
- Body:subject 后空一行,开头,说明意图和原因
- - Footer:body 后空一行,git trailer(如 ),破坏性变更用
Closes #123+ type 后加BREAKING CHANGE: <描述>!
- Subject ≤72 characters, no period
- Body: Blank line after subject, starts with , explains intent and reason
- - Footer: Blank line after body, git trailer (e.g. ), use
Closes #123and addBREAKING CHANGE: <description>after type for breaking changes!
示例
Examples
text
feat(auth): 添加 OAuth2 登录支持
- 实现 Google 和 GitHub 第三方登录
- 添加用户授权回调处理
- 优化登录状态持久化逻辑
Closes #42text
feat(api)!: 重新设计认证 API
- 从 session 认证迁移到 JWT
- 更新所有端点签名
- 移除已废弃的登录方式
BREAKING CHANGE: 认证 API 已完全重新设计,所有客户端需更新集成text
feat(auth): 添加 OAuth2 登录支持
- 实现 Google 和 GitHub 第三方登录
- 添加用户授权回调处理
- 优化登录状态持久化逻辑
Closes #42text
feat(api)!: 重新设计认证 API
- 从 session 认证迁移到 JWT
- 更新所有端点签名
- 移除已废弃的登录方式
BREAKING CHANGE: 认证 API 已完全重新设计,所有客户端需更新集成5. 执行或建议拆分
5. Execute or Suggest Splitting
- 单一逻辑单元:直接提交,无需确认
- 多逻辑单元:建议拆分,等确认后执行
- Single logical unit: Commit directly without confirmation
- Multiple logical units: Suggest splitting, execute after confirmation
6. 执行提交
6. Execute Commit
bash
git commit -m "$(cat <<'EOF'
<type>[(scope)]: <中文描述>
<body>
<footer>
EOF
)"禁止自动推送。仅本地提交,除非用户明确要求。
bash
git commit -m "$(cat <<'EOF'
<type>[(scope)]: <中文描述>
<body>
<footer>
EOF
)"Prohibit automatic push. Only commit locally unless explicitly requested by the user.
7. 提交后
7. After Commit
bash
git log --oneline -1bash
git log --oneline -1安全协议
Security Protocol
- 禁止修改 git config
- 禁止破坏性命令(--force、hard reset)除非用户明确要求
- 禁止跳过 hooks(--no-verify)除非用户明确要求
- 禁止提交含密钥/可能含密钥的文件
- 单一逻辑变更直接提交,多逻辑单元建议拆分后等确认
- 禁止自动推送,仅本地提交
- Prohibit modifying git config
- Prohibit destructive commands (--force, hard reset) unless explicitly requested by the user
- Prohibit skipping hooks (--no-verify) unless explicitly requested by the user
- Prohibit committing files containing secrets or potentially containing secrets
- Commit single logical changes directly; suggest splitting multiple logical units and wait for confirmation
- Prohibit automatic push, only commit locally