feature-branch

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Create a feature branch in a new git worktree, as a sibling directory of the current project.
在当前项目的同级目录中,于新的Git Worktree内创建功能分支。

Steps

步骤

  1. Determine the issue — the argument can be:
    • A GitHub issue number or URL → fetch with
      gh issue view
    • A description → search with
      gh issue list --search "<description>"
      to find the matching issue
    • Nothing → ask the user what they're working on, then search
  2. Generate a branch name:
    • Format:
      <issue-number>-<kebab-case-summary>
      (e.g.
      42-add-user-export
      )
    • Keep it under 50 characters where possible
  3. Ensure
    main
    is up to date:
    • git fetch origin main
  4. Create a worktree as a sibling of the current project directory:
    • git worktree add ../<branch-name> -b <branch-name> origin/main
    • This creates
      ../<branch-name>/
      alongside the current project directory
  5. Confirm to the user:
    • Show the branch name
    • Show the worktree path
    • Summarize what the issue is about
    • Remind them to
      cd ../<branch-name>
      to start working
  1. 确定Issue —— 参数可以是:
    • GitHub Issue编号或URL → 使用
      gh issue view
      获取详情
    • 描述内容 → 使用
      gh issue list --search "<description>"
      搜索匹配的Issue
    • 无参数 → 询问用户正在处理的内容,再进行搜索
  2. 生成分支名称:
    • 格式:
      <issue-number>-<kebab-case-summary>
      (例如:
      42-add-user-export
    • 尽可能保持长度在50个字符以内
  3. 确保
    main
    分支是最新的:
    • git fetch origin main
  4. 在当前项目目录的同级位置创建Worktree:
    • git worktree add ../<branch-name> -b <branch-name> origin/main
    • 此命令会在当前项目目录旁创建
      ../<branch-name>/
      目录
  5. 向用户确认信息:
    • 显示分支名称
    • 显示Worktree路径
    • 概述Issue的内容
    • 提醒用户执行
      cd ../<branch-name>
      开始工作