branch

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Branch

分支

Create a traceable Git branch for the current task.
为当前任务创建可追溯的Git分支。

Workflow

工作流程

  1. Inspect the current Git branch,
    git status
    , and available task context.
  2. Identify the ticket ID when the work comes from an issue tracker. If the task has a ticket but no visible ID, ask for it.
  3. Use the user's branch name if provided; if work from an issue tracker omits the ticket ID, ask before creating it.
  4. Otherwise derive
    <ticket-id>-<short-kebab-summary>
    when there is a ticket ID, or
    <short-kebab-summary>
    when there is not.
  5. Preserve an obvious repo prefix such as
    feature/
    only if the ticket ID remains visible.
  6. If the branch already exists, switch to it. Otherwise, create and switch to it.
  7. Report the branch name and any uncommitted work that was already present.
  1. 检查当前Git分支、
    git status
    以及可用的任务上下文。
  2. 当工作来自问题追踪器时,识别工单ID。如果任务有工单但未显示ID,请询问用户。
  3. 如果用户提供了分支名称则使用该名称;如果来自问题追踪器的工作未包含工单ID,创建分支前请先询问用户。
  4. 否则,当有工单ID时,分支名称格式为
    <ticket-id>-<短横线分隔的简短摘要>
    ;没有工单ID时,格式为
    <短横线分隔的简短摘要>
  5. 仅当工单ID可见时,保留明显的仓库前缀(如
    feature/
    )。
  6. 如果分支已存在,则切换到该分支;否则创建并切换到该分支。
  7. 报告分支名称以及已存在的所有未提交工作。

Rules

规则

  • Stop if the working tree state makes switching branches unsafe.
  • Do not overwrite or discard uncommitted work.
  • Include the ticket ID for work from an issue tracker.
  • Do not invent ticket IDs.
  • 若工作树状态导致切换分支不安全,则停止操作。
  • 不得覆盖或丢弃未提交的工作。
  • 对于来自问题追踪器的工作,需包含工单ID。
  • 不得编造工单ID。