# Using Git Worktrees

> Use when parallel or conflicting work in the same repo needs a separate checkout without stashing — sibling worktree; verify the branch is not already checked out elsewhere.

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

---


# Git worktrees (isolation)

## Core Principle

Isolation without duplicating history: a sibling worktree shares `.git` but keeps
its own working tree and branch.

## When to Use / NOT

- **Use when:** parallel work in one repo, a long-running branch beside main, or
  PR review without disturbing a dirty working tree.
- **NOT when:** one-line fixes on main.

## Workflow

1. `git worktree list` — target branch not already on another worktree.
2. `git status` — commit or stash unrelated dirty state first.
3. `git worktree add -b <branch> ../<repo>-<branch> main` — sibling directory,
   not nested inside the repo.
4. Work and commit in the worktree; remove when done:
   `git worktree remove ../<repo>-<branch> && git worktree prune`.

## Verification

`git worktree list` shows the new path on the intended branch; `pwd` is the
sibling directory, not nested inside the repo.

