creating-worktrees

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Creating Worktrees

创建 Worktree

Steps

步骤

  1. Find repo root:
    git rev-parse --show-toplevel
    .
  2. Get branch or task name; ask once if missing.
  3. Sanitize slug: replace
    /
    , spaces, unusual chars with
    -
    .
  4. Add
    .worktrees/
    to
    $(git rev-parse --git-path info/exclude)
    if missing.
  5. Create: existing branch →
    git worktree add <path> <branch>
    ; new branch →
    git worktree add -b <branch> <path>
    .
  6. codegraph init <path>
    only when source has
    .codegraph/
    or user asks. Else
    CodeGraph: not applicable
    .
  7. Report path, branch, exclude status, CodeGraph result.
  1. 查找仓库根目录:
    git rev-parse --show-toplevel
    。
  2. 获取分支或任务名称;如果缺失,则询问一次。
  3. 清理 slug:将
    /
    、空格和异常字符替换为
    -
    。
  4. 如果尚未添加,则将
    .worktrees/
    添加到
    $(git rev-parse --git-path info/exclude)
    。
  5. 创建:已有分支 →
    git worktree add <path> <branch>
    ;新分支 →
    git worktree add -b <branch> <path>
    。
  6. 仅当源目录包含
    .codegraph/
    或用户提出要求时,才执行
    codegraph init <path>
    。否则输出
    CodeGraph: not applicable
    。
  7. 报告路径、分支、排除状态和 CodeGraph 结果。

Output

输出

End with a short report covering
Report
path/branch,
Sanitized slug
,
Worktree exists
,
Exclusion
, and
CodeGraph
status.
Completion: worktree exists, branch correct, exclusion recorded, CodeGraph reported.
最后以一份简短报告结束,涵盖
Report
路径/分支、
Sanitized slug
、
Worktree exists
、
Exclusion
和
CodeGraph
状态。
完成条件:worktree 存在、分支正确、已记录排除项、已报告 CodeGraph。