git
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit
Git
Clear, repeatable git workflow with a bias toward safety.
清晰、可重复且侧重安全性的Git工作流。
Router
路由机制
Use the smallest workflow that matches the user intent.
| User says | Load reference | Do |
|---|---|---|
| status / what changed (no "worktree" prefix) | | read-only inspection |
| help / usage / man | | show CLI help safely |
| commit / stage | | stage + commit safely |
| branch / switch | | branch operations |
| worktree create/remove/list | | worktree operations |
| worktree cleanup / normalize / consolidate | | auto-clean + consolidate worktrees |
| worktree summary / worktree status / show worktrees | | proactive analysis: PR status, change classification, safe-to-delete verdicts |
| tag / version | | create/list/inspect tags |
| pr / pull request | | create/update PR via gh |
| pr review / fix pr comments / threads | | review + respond + fix |
| merge / rebase / reset / revert | | advanced/recovery (confirm first) |
使用与用户意图匹配的最小工作流。
| 用户指令 | 加载参考文档 | 执行操作 |
|---|---|---|
| status / 查看变更(无"worktree"前缀) | | 只读检查 |
| help / usage / man | | 安全显示CLI帮助 |
| commit / stage | | 安全暂存 + 提交 |
| branch / switch | | 分支操作 |
| worktree create/remove/list | | Worktree操作 |
| worktree cleanup / normalize / consolidate | | 自动清理 + 合并Worktree |
| worktree summary / worktree status / show worktrees | | 主动分析:PR状态、变更分类、可安全删除判定 |
| tag / version | | 创建/列出/查看标签 |
| pr / pull request | | 通过gh创建/更新PR |
| pr review / fix pr comments / threads | | 审查 + 响应 + 修复 |
| merge / rebase / reset / revert | | 高级/恢复操作(需先确认) |
Config (Edit Here)
配置(在此编辑)
Worktree working directories (the folders you into) live outside .
cd.git/Set this once and use it everywhere:
text
WORKTREES_DIR=./.worktrees
WORKTREE_PATH=$WORKTREES_DIR/<topic>If you want a different location (e.g. or ), update above and follow the same shape in .
../.worktrees~/worktrees/<repo>WORKTREES_DIRreferences/worktree-workflow.mdWorktree工作目录(即你执行进入的文件夹)位于外部。
cd.git/只需设置一次即可全局使用:
text
WORKTREES_DIR=./.worktrees
WORKTREE_PATH=$WORKTREES_DIR/<topic>如果你想要不同的存储位置(例如或),请更新上方的,并在中遵循相同格式。
../.worktrees~/worktrees/<repo>WORKTREES_DIRreferences/worktree-workflow.mdResilience Rules (Worktrees)
Worktree弹性规则
- If multiple worktree root folders are detected (example: both and
./.worktrees/exist), do not delete anything by default.../repo-feature-x/ - Prefer consolidating into using
WORKTREES_DIR(when possible) or a remove+re-add plan.git worktree move - If stale metadata exists, propose a cleanup plan: + remove/quarantine orphan directories (with confirmation).
git worktree prune
- 如果检测到多个Worktree根目录(例如和
./.worktrees/同时存在),默认不删除任何内容。../repo-feature-x/ - 优先使用将Worktree合并到
git worktree move中(若可行),或采用删除+重新添加的方案。WORKTREES_DIR - 如果存在过期元数据,建议执行清理计划:+ 删除/隔离孤立目录(需确认)。
git worktree prune
Global Safety Rules (Never Violate)
全局安全规则(严禁违反)
- Never force push to main/master.
- Never commit secrets (env files, keys, credentials).
- Never rewrite history that is already pushed unless explicitly requested.
- Always show what will change before an irreversible action.
- 切勿强制推送到main/master分支。
- 切勿提交机密信息(环境文件、密钥、凭证)。
- 除非明确要求,否则切勿重写已推送的历史记录。
- 在执行不可逆操作前,务必展示将要发生的变更。
Confirmation Policy
快速开始
Read-only commands are always OK.
Everything that changes state/history/remote requires explicit user confirmation:
- ,
git add,git commitgit push - ,
git merge,git rebase,git resetgit revert - ,
git worktree addgit worktree remove - (create/delete)
git tag git branch -d/-D
bash
undefinedQuick Start
只读操作
bash
undefinedgit status
git diff
Read-only
提交
git status
git diff
git diff --cached
git commit -m "feat(scope): why"
Commit
Worktrees操作
git diff --cached
git commit -m "feat(scope): why"
git worktree list
undefinedWorktrees
—
git worktree list
undefined—