Worktree Isolation
Isolate a change in a sibling Git worktree, then merge it from the main checkout and clean up. For records see work-tracker; for commit subjects see conventional-commits.
Steps
basicly worktree create NAME [--base BRANCH] # add and provision .venv, node_modules and hooks
basicly worktree merge NAME --bead RECORD-ID # from the main checkout; --bead is the old flag name for the record id
basicly worktree cleanup NAME # remove the worktree and its merged branch
- Create the worktree when the work will commit. A plain
git worktree add ../REPO.worktrees/NAME -b BRANCHleaves the hooks and environments missing, so it suits read-only work only. - Work and commit inside the worktree.
- Merge from the main checkout. Git refuses to update a branch that another worktree has checked out.
- Clean up. Without
--force, cleanup refuses uncommitted changes and keeps an unmerged branch.
Rules
- Isolate every non-trivial change; skip a typo fix.
- Never set a relative
core.hooksPathin a linked worktree. It silently skips the hooks. - Inspect existing branches and worktrees first. Never replace or discard another session's work.
- Resolve a conflict against the whole task: keep unrelated work and rerun the affected checks.
For several merges in order, stale sessions, cleanup refusals, hook resolution in a linked worktree, protected destinations in an agent sandbox and the Claude Code background isolation setting, read lifecycle.