git

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git

Git

Clear, repeatable git workflow with a bias toward safety.
清晰、可重复且侧重安全性的Git工作流。

Router

路由机制

Use the smallest workflow that matches the user intent.
User saysLoad referenceDo
status / what changed (no "worktree" prefix)
references/read-only.md
read-only inspection
help / usage / man
references/cli-help.md
show CLI help safely
commit / stage
references/commit-workflow.md
stage + commit safely
branch / switch
references/branch-workflow.md
branch operations
worktree create/remove/list
references/worktree-workflow.md
worktree operations
worktree cleanup / normalize / consolidate
references/worktree-maintenance.md
auto-clean + consolidate worktrees
worktree summary / worktree status / show worktrees
references/worktree-summary.md
proactive analysis: PR status, change classification, safe-to-delete verdicts
tag / version
references/tag-workflow.md
create/list/inspect tags
pr / pull request
references/pr-workflow.md
create/update PR via gh
pr review / fix pr comments / threads
references/pr-review-workflow.md
review + respond + fix
merge / rebase / reset / revert
references/advanced-workflows.md
advanced/recovery (confirm first)
使用与用户意图匹配的最小工作流。
用户指令加载参考文档执行操作
status / 查看变更(无"worktree"前缀)
references/read-only.md
只读检查
help / usage / man
references/cli-help.md
安全显示CLI帮助
commit / stage
references/commit-workflow.md
安全暂存 + 提交
branch / switch
references/branch-workflow.md
分支操作
worktree create/remove/list
references/worktree-workflow.md
Worktree操作
worktree cleanup / normalize / consolidate
references/worktree-maintenance.md
自动清理 + 合并Worktree
worktree summary / worktree status / show worktrees
references/worktree-summary.md
主动分析:PR状态、变更分类、可安全删除判定
tag / version
references/tag-workflow.md
创建/列出/查看标签
pr / pull request
references/pr-workflow.md
通过gh创建/更新PR
pr review / fix pr comments / threads
references/pr-review-workflow.md
审查 + 响应 + 修复
merge / rebase / reset / revert
references/advanced-workflows.md
高级/恢复操作(需先确认)

Config (Edit Here)

配置(在此编辑)

Worktree working directories (the folders you
cd
into) live outside
.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.
../.worktrees
or
~/worktrees/<repo>
), update
WORKTREES_DIR
above and follow the same shape in
references/worktree-workflow.md
.
Worktree工作目录(即你执行
cd
进入的文件夹)位于
.git/
外部。
只需设置一次即可全局使用:
text
WORKTREES_DIR=./.worktrees
WORKTREE_PATH=$WORKTREES_DIR/<topic>
如果你想要不同的存储位置(例如
../.worktrees
~/worktrees/<repo>
),请更新上方的
WORKTREES_DIR
,并在
references/worktree-workflow.md
中遵循相同格式。

Resilience Rules (Worktrees)

Worktree弹性规则

  • If multiple worktree root folders are detected (example: both
    ./.worktrees/
    and
    ../repo-feature-x/
    exist), do not delete anything by default.
  • Prefer consolidating into
    WORKTREES_DIR
    using
    git worktree move
    (when possible) or a remove+re-add plan.
  • If stale metadata exists, propose a cleanup plan:
    git worktree prune
    + remove/quarantine orphan directories (with confirmation).
  • 如果检测到多个Worktree根目录(例如
    ./.worktrees/
    ../repo-feature-x/
    同时存在),默认不删除任何内容。
  • 优先使用
    git worktree move
    将Worktree合并到
    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 commit
    ,
    git push
  • git merge
    ,
    git rebase
    ,
    git reset
    ,
    git revert
  • git worktree add
    ,
    git worktree remove
  • git tag
    (create/delete)
  • git branch -d/-D
bash
undefined

Quick Start

只读操作

bash
undefined
git 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
undefined

Worktrees

git worktree list
undefined