worktree-manager

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Worktree Manager

Worktree 管理器

Fast, interactive management of git worktrees with consistent conventions and automatic housekeeping.
基于一致约定与自动清理机制的Git worktree快速交互式管理工具。

Agent behavior contract

Agent行为约定

  1. Always use
    --force
    when removing worktrees — repos with submodules will fail without it.
  2. Always run
    git worktree prune
    after removing a worktree to clean up stale references.
  3. When creating subfolder worktrees, ensure
    .worktrees/
    is in
    .gitignore
    before creating.
  4. Never hardcode worktree paths in remove operations — always read from
    git worktree list
    .
  5. Default to subfolder placement unless the user explicitly chooses parent folder.
  6. Default the worktree folder name to the last segment of the branch name.
  1. 删除worktree时始终使用
    --force
    参数——包含子模块的仓库若不使用该参数会操作失败。
  2. 删除worktree后务必运行
    git worktree prune
    命令以清理过期引用。
  3. 创建子文件夹式worktree时,需先将
    .worktrees/
    添加至
    .gitignore
    再执行创建操作。
  4. 删除操作中切勿硬编码worktree路径——始终从
    git worktree list
    命令的输出中读取路径。
  5. 默认采用子文件夹放置方式,除非用户明确选择父文件夹放置。
  6. worktree文件夹名称默认使用分支名称的最后一段。

Triage (detect action)

分类处理(检测操作)

If the user provided an argument (create, list, or remove), use that action. If no argument was provided, ask the user which action they want:
  • create — Create a new worktree with a new branch
  • list — List all current worktrees
  • remove — Remove an existing worktree
Then read the appropriate reference:
若用户提供了操作参数(create、list或remove),则执行对应操作。 若未提供参数,则询问用户需要执行的操作:
  • create — 创建带有新分支的worktree
  • list — 列出所有当前的worktree
  • remove — 删除已有的worktree
之后读取对应的参考文档:

Routing map

路由映射

  • Creating a worktree
    references/creating.md
  • Listing worktrees
    references/listing.md
  • Removing a worktree
    references/removing.md
  • Placement strategies & conventions
    references/placement.md
  • Common issues & troubleshooting
    references/troubleshooting.md
  • 创建worktree
    references/creating.md
  • 列出worktrees
    references/listing.md
  • 删除worktree
    references/removing.md
  • 放置策略与约定
    references/placement.md
  • 常见问题与故障排查
    references/troubleshooting.md

Common errors → next best move

常见错误→最佳解决步骤

  • "working trees containing submodules cannot be moved or removed" → use
    --force
    flag (see
    references/removing.md
    )
  • Stale worktree references after manual deletion → run
    git worktree prune
    (see
    references/removing.md
    )
  • Branch already checked out in another worktree → list worktrees to find which one, remove or use a different branch
  • .worktrees/
    showing up in git status
    → add to
    .gitignore
    (see
    references/placement.md
    )
  • "working trees containing submodules cannot be moved or removed" → 使用
    --force
    标记(详见
    references/removing.md
  • 手动删除后存在过期worktree引用 → 运行
    git worktree prune
    命令(详见
    references/removing.md
  • 分支已在另一个worktree中检出 → 列出所有worktree以找到对应项,删除该worktree或使用其他分支
  • .worktrees/
    出现在git状态中
    → 将其添加至
    .gitignore
    (详见
    references/placement.md