# Git Worktree

> Create isolated git worktrees in ~/.claude-worktrees/. Use when user says "create an isolated copy", "worktree", "create worktree", "isolated workspace", or needs to work on a branch without affecting the main working directory. Use when this capability is needed.

- Skill: `tomevault-io/git-worktree-2` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/git-worktree-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/git-worktree-2/raw
- Safety review: pending (external: skill-scanner PASS, skillspector CAUTION)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/git-worktree-2

---


# Git Worktree

Create isolated git worktrees in `~/.claude-worktrees/<repo>/<branch>/`.

Supports `.worktreeinclude` file for copying untracked files (e.g., `.env.local`) to new worktrees.

## Usage

### Create Worktree

```bash
BRANCH_NAME="feature/my-feature" ./scripts/create-worktree.sh
# Or with ticket URL for branch naming:
BRANCH_NAME="eng-123/fix-bug" TICKET_URL="https://linear.app/team/issue/ENG-123/fix-bug" ./scripts/create-worktree.sh
# Or with custom base branch:
BRANCH_NAME="feature/my-feature" BASE_BRANCH="develop" ./scripts/create-worktree.sh
```

**Outputs** (to stdout):
- `BRANCH_NAME=<branch>` - The created branch name
- `WORKTREE_PATH=<path>` - Absolute path to worktree
- `DEFAULT_BRANCH=<branch>` - Repository's default branch

### Remove Worktree

```bash
WORKTREE_PATH="$HOME/.claude-worktrees/my-repo/my-branch" ./scripts/remove-worktree.sh
```

## .worktreeinclude

Create a `.worktreeinclude` file in your repo root to specify files that should be copied to new worktrees:

```
# Environment files
.env.local
.env.development

# Local config
config/local.json
```

Supports glob patterns via bash globbing (`**/*.local`).

## Scripts

- `create-worktree.sh` - Create worktree, copy includes
- `copy-worktree-includes.sh` - Copy files from .worktreeinclude
- `remove-worktree.sh` - Remove worktree and clean up

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/kvnxiao) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-14 -->

