using-git-worktrees 是什么?
using-git-worktrees 为开发任务准备隔离工作区。它先检查当前是否已在worktree中,再优先使用Agent平台自带的隔离工具;没有原生方式时才用Git worktree,并检查目录忽略规则与项目基线。
中文说明由本站依据来源整理;英文原文保留在页面下方。
适合用在
- 需要在不干扰当前工作区的情况下开发功能,或执行已经确认的实现计划。
这些情况不适合
- 非Git目录;也不能看到路径像普通目录就断定当前没有隔离。
- 平台已管理worktree时再手工创建一套,让平台无法追踪状态。
怎么接入你的 Agent?
- 定位完整 Skill 目录
打开本项目来源,核对
SKILL.md及其引用的脚本和资料。 - 交给你正在用的 Agent
在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。
- 确认识别,再做具体任务
让 Agent 回报安装目录和识别到的名称
using-git-worktrees,然后按本页使用示例提供材料。
展开并复制给 Codex 的安装指令
安装并检查 using-git-worktrees
请在 Codex 的当前工作环境中安装并检查 using-git-worktrees 这个 Skill。
项目身份:obra/superpowers / using-git-worktrees
来源:https://github.com/obra/superpowers/blob/22f0b463e7a5e579904dd6211a520321035526f7/skills/using-git-worktrees/SKILL.md
已定位的源文件:skills/using-git-worktrees/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Claude Code 的安装指令
安装并检查 using-git-worktrees
请在 Claude Code 的当前工作环境中安装并检查 using-git-worktrees 这个 Skill。
项目身份:obra/superpowers / using-git-worktrees
来源:https://github.com/obra/superpowers/blob/22f0b463e7a5e579904dd6211a520321035526f7/skills/using-git-worktrees/SKILL.md
已定位的源文件:skills/using-git-worktrees/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Cursor 的安装指令
安装并检查 using-git-worktrees
请在 Cursor Agent 的当前工作环境中安装并检查 using-git-worktrees 这个 Skill。
项目身份:obra/superpowers / using-git-worktrees
来源:https://github.com/obra/superpowers/blob/22f0b463e7a5e579904dd6211a520321035526f7/skills/using-git-worktrees/SKILL.md
已定位的源文件:skills/using-git-worktrees/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 当前 Agent 的安装指令
安装并检查 using-git-worktrees
请在 当前 Agent 的当前工作环境中安装并检查 using-git-worktrees 这个 Skill。
项目身份:obra/superpowers / using-git-worktrees
来源:https://github.com/obra/superpowers/blob/22f0b463e7a5e579904dd6211a520321035526f7/skills/using-git-worktrees/SKILL.md
已定位的源文件:skills/using-git-worktrees/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。装好以后,具体怎么用?
准备哪些材料
- 项目必须是实际Git仓库,确认用户已有工作区偏好、允许的目录与当前分支;工具链、依赖和基线测试命令来自工程本身。
会得到什么
- 工作区绝对路径、分支或detached状态、采用的隔离方式,以及实际基线检查结果。
实际使用顺序
- 读取
git rev-parse --git-dir、--git-common-dir与当前分支,并用--show-superproject-working-tree排除子模块,避免把子模块误认成linked worktree。 - 已隔离则继续使用,不重复创建。需要新隔离时按已有授权与偏好选择平台原生工具;没有原生工具才使用Git方式。
- 项目内目录先用
git check-ignore确认忽略状态,再选明确分支和路径创建;不要把占位路径直接运行,也不顺带提交无关改动。 - 按真实工程准备依赖并运行基线检查,记录原有失败;创建被环境权限阻挡时说明实际限制,不把失败写成隔离已完成。
从一个具体任务开始
本站根据源文件编写的使用示例,未在本站实际运行。示例中的文件由你提供。
复制一个具体任务
使用 using-git-worktrees 检查当前Git项目是否已经隔离。我已同意为“CSV导出修复”使用独立工作区;若平台已有隔离工具请优先使用,若已经在worktree里就沿用。请先核对分支与子模块状态,再按项目既有目录规范准备环境并运行实际基线测试,报告路径和原有失败。预期复用或创建一个状态明确的隔离工作区,不重复建立平台无法管理的目录。本站未执行本例。
使用条件与边界
- worktree共享Git仓库对象与部分配置,不等同于独立虚拟机、账号或运行环境。
- 新工作区仍可能有依赖和基线测试问题;目录创建成功不意味着项目可运行。
常见问题
为什么要单独排除Git子模块?
子模块的Git目录与公共目录也可能不同,单看这个差异会误判为linked worktree,来源专门要求检查superproject。
当前已经是detached HEAD怎么办?
来源允许继续使用外部管理的隔离工作区,但要如实记录detached状态,完成集成时再处理分支,不再创建另一套worktree。
来源原文与资料状态
- 源文件
- 已保存 SKILL.md,抓取于 2026-11-17T19:31:50.806Z
- 中文使用说明
- 已针对下方源文件版本整理用途、用法和常见问题
- 安装与任务测试
- 本站未执行安装或任务测试
- 来源复核
- 本页中文用法已对照保存版本的完整 SKILL.md 阅读整理
展开 SKILL.md 原文、章节与历史收录资料
skills/using-git-worktrees/SKILL.md · 抓取时间 2026-11-17T19:31:50.806Z
以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。
抓取成功不代表已完成安装或任务测试。
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback
查看源文件章节 / Source sections
- 原文:Using Git Worktrees
- 原文:Overview
- 原文:Step 0: Detect Existing Isolation
- 原文:Step 1: Create Isolated Workspace
- 原文:1a. Native Worktree Tools (preferred)
- 原文:1b. Git Worktree Fallback
- 原文:Directory Selection
- 原文:Safety Verification (project-local directories only)
- 原文:Create the Worktree
- 原文:Step 2: Project Setup
- 原文:Step 3: Verify Clean Baseline
- 原文:Report
- 原文:Quick Reference
- 原文:Common Rationalizations
原文:Overview
Ensure work happens in an isolated workspace. Prefer your platform's native worktree tools. Fall back to manual git worktrees only when no native tool is available. **Core principle:** Detect existing isolation first. Then use native tools. Then fall back to git. Never fight the harness. **Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace."
原文:Step 0: Detect Existing Isolation
**Before creating anything, check if you are already in an isolated workspace.** ```bash GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P) GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P) BRANCH=$(git branch --show-current) ``` **Submodule guard:** `GIT_DIR != GIT_COMMON` is also true inside git submodules. Before concluding "already in a worktree," verify you are not in a submodule: ```bash # If this returns a path, you're in a submodule, not a worktree — treat as normal repo git rev-parse --show-superproject-working-tree 2>/dev/null ``` **If `GIT_DIR != GIT_COMMON` (and not a submodule):** You are already in a linked worktree. Skip to Step 2 (Project Setup). Do NOT create another worktree. Report with branch state: - On a branch: "Already in isolated workspace at `<path>` on branch `<name>`." - Detached HEAD: "Already in isolated workspace at `<path>` (detached HEAD, externally managed). Branch creation needed at finish time." **If `GIT_DIR == GIT_COMMON` (or in a submodule):** You are in a normal repo checkout. Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree: > "Would you like me to set up an isolated worktree? It protects your current branch from changes." Honor any existing declared preference without asking. If the user declines consent, work in place and skip to Step 2.
原文:Step 1: Create Isolated Workspace
**You have two mechanisms. Try them in this order.**
原文:1a. Native Worktree Tools (preferred)
The user has asked for an isolated workspace (Step 0 consent). Do you already have a way to create a worktree? It might be a tool with a name like `EnterWorktree`, `WorktreeCreate`, a `/worktree` command, or a `--worktree` flag. If you do, use it and skip to Step 2. Native tools handle directory placement, branch creation, and cleanup automatically. Using `git worktree add` when you have a native tool creates phantom state your harness can't see or manage. Only proceed to Step 1b if you have no native worktree tool available.
原文:1b. Git Worktree Fallback
**Only use this if Step 1a does not apply** — you have no native worktree tool available. Create a worktree manually using git.
原文:Directory Selection
Follow this priority order. Explicit user preference always beats observed filesystem state. 1. **Check your instructions for a declared worktree directory preference.** If the user has already specified one, use it without asking. 2. **Check for an existing project-local worktree directory:** ```bash ls -d .worktrees 2>/dev/null # Preferred (hidden) ls -d worktrees 2>/dev/null # Alternative ``` If found, use it. If both exist, `.worktrees` wins. 3. **If there is no other guidance available**, default to `.worktrees/` at the project root.
文件 SHA256:8cfb86f121269e8f7f12361e6795c4f6738828340e28964c9229d365666c9edd
仓库许可证记录:MIT;repository-license-recorded-scope-unverified,查看来源。
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via…
这份历史简介在采集时已截断;完整用途和触发条件需打开来源核对。
历史收录数据
| Skill标识 | using-git-worktrees |
|---|---|
| 来源仓库 | obra/superpowers |
| 榜单快照 | 2026-07-28 |
| 榜单口径 | Skills.sh累计安装量 |
| 快照名次 | 180 |
| 快照累计安装量 | 147822 |
历史资料说明
- 所保留的来源简介在采集时已截断;完整触发条件、依赖及排除项须阅读源文件,本站不补写缺失部分。
- 安装量用于说明当时的收录次序,不是效果、可信度或当前可用性的证明。
此页用于识别项目与来源。安装入口可在该Skill的Skills.sh页面查看;当前目录是否仍存在、附带脚本和账户依赖尚需按具体版本确认。
