Work in a git worktree
Give each agent its own branch and folder with a git worktree, so agents working at once never edit the same files.
Run two agents on one project without them editing the same files. Each gets a worktreeA second checkout of the same git repository in its own folder, on its own branch, so two agents never edit the same files.Glossary →: its own folder and branch.
Paste this into your coding agent to set up a worktree with its own agent.
Show the prompt
Set up a git worktree for a new task in this project, open it in Hivemind and start an agent there. 1. Check Hivemind is open on this project: `hive ctl frames --json` answers. If it exits 3, tell me to open Hivemind on the project and stop. 2. Ask me for a branch name for the task and which agent to use. 3. Make the worktree beside the project: `git worktree add ../<project>-worktrees/<branch> -b <branch>`. If the branch exists already, leave out -b. Do not delete or reset any branch. 4. Open it as a frame: `hive ctl frame add --folder <full path of the worktree> --name <branch>`. 5. Start the agent in it: `hive ctl spawn --frame <branch> --agent <agent> --prompt "<the task I give you>"`. Check: `hive ctl agents` lists the new agent, and `git -C <worktree path> branch --show-current` prints the branch. Tell me the worktree path, its branch and the agent's tile id. REFERENCE https://hivemind.griiken.com/guide/git-worktree.md
Before you start
- The project is a git repository, opened in Hivemind.
- The repository has no submodules. Git worktrees do not support them.
Make a worktree in the app
- Open the project frame's ⋯ menu and choose Worktree.
- Choose Create new worktree, type a new branch name, and press create.
- Check: a new frame appears, nested under the project, named after the branch.
- Select the new frame and press 2 to start your default agent there.
- Check: the agent's tile shows the worktree's folder, not the project's.
Hivemind puts a new worktree in ../<project>-worktrees/<branch>, beside the project. To open a
worktree that already exists, pick it from the same Worktree menu.
Make a worktree in a terminal
- Make the worktree with git:
git worktree add ../myproject-worktrees/fix-login -b fix-login. - Open it as a frame:
hive ctl frame add --folder ~/src/myproject-worktrees/fix-login --name fix-login. - Check: the command prints the new frame's id, and the frame appears on the canvas.
- Start an agent in it:
hive ctl spawn --frame fix-login --agent claude --prompt "Fix the login redirect".
Check it worked
git worktree listshows the new folder and branch.- The agent's work lands on its own branch.
git -C <worktree> statusshows its changes. - The project folder's own branch stays as it was.
If it didn't
| You see | Do |
|---|---|
branch … is already checked out at … | Another worktree uses that branch. Pick a new name, or open that worktree. |
repo has submodules | Git worktrees do not support submodules. Use a separate clone instead. |
| No Worktree item in the frame menu | The frame is not on a git repository, or it is already a worktree. |
Related
- Run many agents at once: a tutorial with three worktrees.
- Workspaces, frames and tiles
- Review an agent's changes
Last validated for Hivemind 2026.10.3.