using-git-worktrees
Installation
SKILL.md
What git worktrees solve
git worktree lets one repo have multiple checked-out branches in separate directories simultaneously. Without worktrees, the choices are:
- Branch-switch with stash —
git stashyour work,git switch other-branch, do work,git switch back,git stash pop. Loses the running build artifacts, IDE state, open files. Stash conflicts are a recurring sharp edge. - Multiple clones —
git clonethe repo into a second directory. Costs disk space (full.git/× N) and de-syncs (each clone has its own remote refs, branch list, hooks). - Just don't context-switch — works until reality forces a switch (production bug while feature is in flight).
git worktree is a fourth option: one .git/ shared across N checkouts in N directories, each on its own branch. Cheap to create (no full clone); cheap to destroy (just delete the directory + git worktree prune); fully synced (one remote, shared hooks, shared object store).