# Git Worktrees

> Manage git worktrees for parallel development. Use when user mentions worktrees, parallel branches, or working on multiple branches simultaneously.

- Skill: `yurifrl/git-worktrees` (Agent Skill)
- Install (CLI): `npx skillmds@latest add yurifrl/git-worktrees`
- Raw SKILL.md: https://api.skillmd.com/api/skills/yurifrl/git-worktrees/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: yurifrl (https://skillmd.com/u/yurifrl)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/yurifrl/git-worktrees

---


# Git Worktrees

Work on multiple branches simultaneously without stashing or switching.

## Worktree Location

All worktrees live in `.worktrees/` at repo root.

```
project/
├── .worktrees/
│   ├── feat-auth/
│   └── fix-login/
└── (main working tree)
```

## Naming Convention

Worktree folder matches branch name pattern:

| Branch | Worktree Folder |
|--------|-----------------|
| `yurifrl/feat/auth` | `.worktrees/feat-auth` |
| `yurifrl/fix/login-bug` | `.worktrees/fix-login-bug` |
| `hotfix/urgent` | `.worktrees/hotfix-urgent` |

**Pattern**: Take the last two segments, join with hyphen.

## Commands

### Create Worktree

```bash
# New branch
git worktree add .worktrees/<folder> -b <branch-name>

# Existing branch
git worktree add .worktrees/<folder> <existing-branch>
```

### List Worktrees

```bash
git worktree list
```

### Remove Worktree

```bash
git worktree remove .worktrees/<name>
```

### Prune Stale

```bash
git worktree prune
```

## Workflow

- Create worktree for feature/fix work
- Each worktree is independent (own node_modules, build cache, etc.)
- Remove worktree when branch is merged
- Run `git worktree prune` to clean up stale references

## Tips

- Worktrees share the same `.git` - commits are visible everywhere
- Don't forget to install dependencies in new worktree

