How Worktrees Work
The Problem
You have one repo. Two people (or two AIs) need to work on it at the same time. If they share one directory, switching branches changes the files for everyone. Work disappears.The Solution
A git worktree is a second checkout of the same repo. Same history, same remote, different branch, different directory. No cloning. No duplication..git database. Commits in any worktree are visible to all. But each has its own branch and files on disk.
How to Create
_worktrees/my-repo--my-prefix--fix-bug/.
How to Work
Edit files in the worktree directory. Commit, push, PR, merge as normal:How to Clean Up
Rules
- Main working tree stays on main. Read-only. All edits in worktrees.
- One branch per worktree. Don’t switch branches inside a worktree.
- Commit and push before closing. Uncommitted work is lost when the worktree is removed.
- Use branch prefixes to prevent collisions between people/AIs.
- Releases run from main, not from worktrees.