Token导航 LogoToken导航

Agent Skill · 开发

git-worktree(Git 工作树)

git-worktree 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

git-worktree 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为执行命令;许可证信息还不明确,第三方扫描有提醒项,按安装量在开发类的 21,746 个 Skill 里排第 14,749。

总安装 665周安装 28GitHub Stars 2下载 233核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:git-worktree(Git 工作树)
来源仓库:https://github.com/antjanus/skillbox
仓库路径:skills/git-worktree
安装命令:
npx skills add https://github.com/antjanus/skillbox --skill git-worktree
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/antjanus/skillbox --skill git-worktree

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

用于管理 Git 工作树,支持多分支并行开发和独立工作目录操作。适合在 Codex、Claude、Cursor、Gemini CLI 中进行分支隔离测试和紧急修复。可检查状态、创建工作树并清理引用,提升开发效率。

安装命令:npx skills add https://github.com/antjanus/skillbox --skill git-worktree。注意确认是否涉及 Git 命令执行和文件系统操作。

来源仓库内路径:skills/git-worktree

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/antjanus/skillbox --skill git-worktree;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要执行命令,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

git-worktree 怎么安装?

在终端执行 npx skills add https://github.com/antjanus/skillbox --skill git-worktree。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

git-worktree 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

git-worktree 需要什么权限?

权限级别是执行命令。安装流程涉及命令执行,可能通过 npx skills add https://github.com/antjanus/skillbox --skill git-worktree 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

git-worktree 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

git-worktree 用的人多吗?

公开数据是累计安装 665 次,近一周安装 28 次,下载 233 次,GitHub 2 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

git-worktree 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 需要执行命令,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

  • 不能接受 Skill 在你机器上执行命令的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
git-worktree

Git 工作树 · 本页

6652执行命令未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Git Worktree - Parallel Development

Overview

Git worktrees enable multiple working directories from a single repository. Each worktree has its own branch while sharing the same Git object database.

Core principle: Check worktree status, create worktree for parallel work, reference cleanup commands as needed.

When to Use

Use worktrees when:

  • Working on multiple branches simultaneously
  • Emergency hotfix needed without disrupting current work
  • Reviewing PRs in isolation
  • Testing across branches without stashing

Avoid when:

  • Quick branch switch (use git switch instead)
  • Single feature, single branch workflow

The Workflow

Step 1: Check Worktree Status

Before creating a worktree, check what already exists:

# List all worktrees
git worktree list

# Verbose output with branch info
git worktree list --verbose

Step 2: Create Worktree

Basic creation:

# Create worktree with new branch from HEAD
git worktree add ../project-feature-name -b feature-name

# Create from specific base branch
git worktree add ../project-hotfix -b hotfix-critical origin/main

# Create from existing remote branch
git worktree add ../project-review pr-123

Tip: Place worktrees outside the repo directory (e.g., ../project-feature-name) so they aren't tracked by Git.

Recommended configuration (run once):

git config worktree.guessRemote true
git config worktree.useRelativePaths true  # Requires Git 2.45+

Step 3: Work in Worktree

Navigate to the worktree and work normally:

cd ../project-feature-name
# Install dependencies, run tests, start Claude, etc.

Worktree Management Reference

These commands are available for managing worktrees. Surface these to the user when relevant:

List worktrees:

# List all worktrees
git worktree list

# Verbose output with branch and commit info
git worktree list --verbose

Remove worktrees:

# Remove a worktree (must have no uncommitted changes)
git worktree remove ../project-feature-name

# Force remove (discards uncommitted changes)
git worktree remove -f ../project-feature-name

Prune stale worktrees:

# Clean up metadata for manually deleted worktrees
git worktree prune

# Dry run to see what would be pruned
git worktree prune -n

# Repair a disconnected worktree
git worktree repair ../project-feature-name

Troubleshooting

"Another worktree already uses this branch"

Cause: Can't checkout same branch in multiple worktrees.

Solution:

# Check which worktree has it
git worktree list | grep branch-name

# Create new branch from same base instead
git worktree add ../new-path -b branch-copy origin/branch-name

"Worktree contains modified or untracked files"

Cause: Can't remove worktree with uncommitted changes.

Solution:

# Commit or stash changes first
cd ../project-feature-name
git add . && git commit -m "Final changes"

# Or force remove (discards changes)
git worktree remove -f ../project-feature-name

Stale Worktree References

Cause: Manually deleted worktree directory without git worktree remove.

Solution:

# List worktrees (shows "prunable" entries)
git worktree list --verbose

# Clean up stale metadata
git worktree prune

Examples

Example 1: Create worktree for new feature

Create worktree with descriptive branch name

git worktree add../myproject-auth -b feature/auth cd../myproject-auth

Install dependencies and verify setup

npm install npm test

**Why this is good:** Checks existing worktrees, uses descriptive naming, verifies setup before work.
</Good>

<Bad>

Create worktree without checking existing ones

git worktree add ../temp -b temp cd ../temp


**Why this is bad:** No verification of existing worktrees, vague naming makes tracking difficult, no setup verification.

### Example 2: Emergency hotfix pattern

# Fix bug, test, commit

npm test git add. git commit -m "Fix payment processor race condition" git push -u origin hotfix/payment-bug

# Return to original work

cd../myproject git worktree remove../myproject-hotfix

Why this is good: Branches from correct base (main), tests before committing, cleans up after. </Good>

<Bad>

# Create hotfix from current feature branch
git worktree add ../fix -b fix
cd ../fix
# Make changes, forget to clean up

Why this is bad: Wrong base branch (includes feature work), vague naming, no cleanup.

Example 3: Review PR without switching

Review and test

npm install npm test

Leave comments, then clean up

cd../myproject git worktree remove../myproject-pr-123

**Why this is good:** Fetches PR properly, uses PR number in path, cleans up after review.
</Good>

<Bad>

Try to checkout PR in main worktree

git checkout pr-123 # Loses current work


**Why this is bad:** Switches branch in main worktree, loses current state, forces stashing.

## Integration

**This skill enables:**

- Working on multiple branches simultaneously without context switching
- Running parallel Claude Code sessions (one per worktree)
- Emergency hotfixes without disrupting feature work
- Safe PR review in isolated environments

**Pairs with:**

- **track-session** - Create separate SESSION_PROGRESS.md in each worktree to track independent progress
- **commit workflows** - Each worktree has its own staging area and commits independently
- **Parallel Claude sessions** - Name each Claude session after its worktree branch for clarity

**Integration pattern with track-session:**

Create worktree

git worktree add ../myproject-feature -b feature/new-api cd ../myproject-feature

Create independent progress tracking

echo "# Session Progress - New API Feature" > SESSION_PROGRESS.md

Start Claude session named "myproject - New API Feature"

Work proceeds with independent progress tracking


**Multi-worktree workflow:**

Terminal 1: Feature work in main worktree

cd ~/myproject

Claude session: "myproject - main"

Terminal 2: Hotfix in separate worktree

cd ~/myproject-hotfix

Claude session: "myproject - hotfix"

Terminal 3: PR review in separate worktree

cd ~/myproject-pr-123

Claude session: "myproject - PR review"


**Best practices:**

- Name Claude sessions to match worktree purpose
- Each worktree tracks progress independently
- Use `git worktree list` to see all active work
- Clean up worktrees when branches are merged

## References

- [Git Worktree Documentation](https://git-scm.com/docs/git-worktree)
- [Git Worktree Tutorial](https://git-scm.com/docs/git-worktree#_examples)

平台分布

Codex

35.39%
按下载量换算82

Claude

31.48%
按下载量换算73

Cursor

16.43%
按下载量换算38

Gemini CLI

8.44%
按下载量换算20

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/antjanus/skillbox --skill git-worktree 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills