git-worktree
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit Worktree
Git Worktree
Overview
概述
This skill allows you to quickly create a new git worktree for the current project. The worktree is created in the same parent directory as the current project's root, following the naming convention .
PROJECT-NAME-T-BRANCH-NAME本技能可帮助你快速为当前项目创建新的git worktree。该worktree会创建在当前项目根目录的父目录下,遵循命名格式。
PROJECT-NAME-T-BRANCH-NAMEWorkflow
工作流程
-
Verification:
- Verify the current directory is within a Git repository.
- Identify the absolute path of the project's root.
-
User Interaction: Proactively suggest values for the required parameters. Ask the user for:
- New branch name: The name of the branch to be created. Suggest a context-aware name (e.g., or
feat-improvementbased on context.fix-issue-123 - Base branch: The branch to base the new branch on (Default: the current branch).
Crucially, if the user does not respond to a question or provides no alternative, proceed immediately using your suggested values instead of repeating the question. The goal is to minimize friction while allowing for customization. - New branch name: The name of the branch to be created. Suggest a context-aware name (e.g.,
-
Path Calculation: Calculate the new worktree path at the same directory level as the project root. For example, if the project is in, the worktree will be created at
/Users/user/my-project./Users/user/my-project-T-NEW-BRANCH -
Creation: Executeto:
scripts/create_worktree.sh- Create the new worktree and branch.
- Perform initial project setup (e.g., ,
flutter pub get).npm install
-
Confirmation: Report the location of the new worktree and any initial setup status.
-
Management: Useto:
scripts/manage_worktrees.sh- List all current project worktrees.
- Interactively select and remove a specific worktree.
-
验证:
- 验证当前目录是否位于Git仓库内。
- 确定项目根目录的绝对路径。
-
用户交互:主动建议所需参数的取值。向用户询问:
- 新分支名称:要创建的分支名称。建议一个上下文相关的名称(例如根据上下文建议或
feat-improvement)。fix-issue-123 - 基础分支:新分支基于的分支(默认值:当前分支)。
重要提示:如果用户未回复问题或未提供替代值,请立即使用你建议的取值继续操作,而非重复提问。目标是在允许自定义的同时尽可能减少操作阻碍。 - 新分支名称:要创建的分支名称。建议一个上下文相关的名称(例如根据上下文建议
-
路径计算:计算新worktree的路径,使其与项目根目录处于同级目录。例如,如果项目位于,则worktree将创建在
/Users/user/my-project。/Users/user/my-project-T-NEW-BRANCH -
创建:执行以:
scripts/create_worktree.sh- 创建新的worktree和分支。
- 完成项目初始设置(例如、
flutter pub get)。npm install
-
确认:告知用户新worktree的位置以及初始设置的状态。
-
管理:使用来:
scripts/manage_worktrees.sh- 列出当前项目的所有worktree。
- 交互式选择并删除特定的worktree。
Usage Example
使用示例
User: "Create a worktree for this repo."
Gemini: "I'll create a new worktree for you. I'll use the branch name based on the current branch . Is that okay, or would you like a different name?"
User: "That's fine."
Gemini: [Runs the script and confirms the path ]
feat-wyatt_skills-260221main/Users/huwentao/_proj/wyatt_skills-T-feat-wyatt_skills-260221Another Example (Proactive/No Response):
User: "Create a worktree for feature-login."
Gemini: "I'll create a worktree for based on . Starting the setup now..."
Gemini: [Runs the script and confirms the path ]
feature-loginmain/Users/huwentao/_proj/foo_proj-T-feature-loginManage Worktrees:
User: "Show my worktrees and help me delete one."
Gemini: "Here are your current worktrees. Which one would you like to remove?"
Gemini: [Lists worktrees and prompts for selection via ]
scripts/manage_worktrees.sh用户:"为这个仓库创建一个worktree。"
Gemini:"我将为你创建一个新的worktree。我会基于当前分支使用分支名称。这样可以吗?还是你想要一个不同的名称?"
用户:"可以。"
Gemini:[运行脚本并确认路径]
mainfeat-wyatt_skills-260221/Users/huwentao/_proj/wyatt_skills-T-feat-wyatt_skills-260221另一个示例(主动处理/无回复):
用户:"为feature-login创建一个worktree。"
Gemini:"我将基于为创建worktree。现在开始设置..."
Gemini:[运行脚本并确认路径]
mainfeature-login/Users/huwentao/_proj/foo_proj-T-feature-login管理Worktree:
用户:"显示我的worktree并帮我删除一个。"
Gemini:"以下是你当前的所有worktree。你想要删除哪一个?"
Gemini:[通过列出worktree并提示用户选择]
scripts/manage_worktrees.shResources
资源
scripts/
scripts/
- : A bash script that calculates the paths, runs
create_worktree.sh, and performs initial project setup.git worktree add- Arguments:
project_pathnew_branchbase_branch
- Arguments:
- : A script to list and interactively remove worktrees.
manage_worktrees.sh- Arguments:
project_path
- Arguments:
- :一个bash脚本,用于计算路径、运行
create_worktree.sh并完成项目初始设置。git worktree add- 参数:
project_pathnew_branchbase_branch
- 参数:
- :一个用于列出并交互式删除worktree的脚本。
manage_worktrees.sh- 参数:
project_path
- 参数: