# git-worktrees

Teaches your AI coding assistant to manage multiple linked Git working trees. Helpful for handling hotfixes, PR reviews, and parallel builds without stashing changes.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 1200 installs · ★ 1787
- Author: NeoLabHQ
- License: GPL-3.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/NeoLabHQ/context-engineering-kit/tree/HEAD/skills/git-worktrees/SKILL.md
- Updated: 2026-08-26
- HTML: https://affpapa.org/en/nevibecode/skills/git-worktrees

## What it does

This skill guides coding agents through Git worktree workflows. Instead of cloning a repository twice or stashing work, developers can keep multiple checkouts linked to the same `.git` object database. Context switching happens simply by changing directories.

The instructions cover creating linked trees, tracking remote branches, side-by-side file comparisons, and cleaning up stale references. Git enforces a strict rule: a single branch cannot be checked out in two worktrees at once. Deleting a dirty directory requires the `--force` flag. That safeguard protects uncommitted edits from accidental loss during project cleanup.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add NeoLabHQ/context-engineering-kit --skill git-worktrees -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/git-worktrees/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/git-worktrees/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add NeoLabHQ/context-engineering-kit --skill git-worktrees -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/git-worktrees/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add NeoLabHQ/context-engineering-kit --skill git-worktrees -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/git-worktrees/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install NeoLabHQ/context-engineering-kit git-worktrees
```

2. **Manually: put the files in place**
- File: `.github/skills/git-worktrees/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add NeoLabHQ/context-engineering-kit --skill git-worktrees -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/NeoLabHQ/context-engineering-kit --path skills/git-worktrees
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/git-worktrees/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add NeoLabHQ/context-engineering-kit --skill git-worktrees -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/NeoLabHQ/context-engineering-kit/tree/HEAD/skills/git-worktrees/SKILL.md

## When to use it
- isolate urgent hotfixes without stashing ongoing work
- inspect pull requests in dedicated folders while keeping code active
- diff implementations across two distinct branches side by side
- run background test suites in a clean directory
- cherry-pick selected changes across multiple working copies

## Example prompts
- Create a new worktree for branch hotfix-456 from main in a sibling directory.
- Set up an isolated worktree to review pull request 123 and run tests there.
- Compare src/module.js between the main worktree and feature-1 worktree.

## Similar
- [using-git-worktrees](https://affpapa.org/en/nevibecode/skills/ganyuanran-using-git-worktrees.md) — skill · ★ 1384
- [git-worktree-manager](https://affpapa.org/en/nevibecode/skills/git-worktree-manager.md) — skill · 581 installs
- [create-worktrees](https://affpapa.org/en/nevibecode/commands/create-worktrees.md) — command · 351 installs
- [git-pushing](https://affpapa.org/en/nevibecode/skills/sickn33-git-pushing.md) — skill · 918 installs
- [git-worktree-runner](https://affpapa.org/en/nevibecode/skills/git-worktree-runner.md) — skill · ★ 1552
- [git-advanced-workflows](https://affpapa.org/en/nevibecode/skills/git-advanced-workflows.md) — skill · 19356 installs

From the same set: [neolabhq/context-engineering-kit](https://affpapa.org/en/nevibecode/by/neolabhq/context-engineering-kit.md) — 64 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
