Skip to content

Worktrees

A git worktree lets you check out multiple branches of the same repository into separate folders simultaneously. Ptah has first-class support for worktrees because they pair naturally with agent-driven development: you can have an agent working on a feature branch in one worktree while you review a PR in another, without stashing or switching.

When an agent runs a long task — say, a multi-file refactor or a test suite run — you can’t safely switch branches on the same working tree. Stashing is fragile, and cancelling the agent loses work.

Worktrees sidestep this entirely. Each agent can be pinned to its own worktree, and you keep your main working tree free for reading, reviewing, or starting new tasks.

ScenarioWithout worktreesWith worktrees
Review a PR while an agent refactorsStash, checkout, un-stashgit worktree add ../review pr-123
Run agents on two features in parallelSerial execution onlyTwo worktrees, two concurrent agents
Hotfix on main during feature workStash or commit WIP firstAdd a worktree on main, fix, push

From the UI: View → Git Worktrees → Add worktree. Pick a target folder and either an existing branch or a new branch name.

From an agent, using the MCP tool:

{
"tool": "ptah_git_worktree_add",
"arguments": {
"path": "../my-project-feature-x",
"branch": "feature/x",
"createBranch": true
}
}

Equivalent shell:

Terminal window
git worktree add -b feature/x ../my-project-feature-x

The Git Worktrees panel shows every worktree linked to the current repo, with its path, branch, and HEAD commit. Clicking a worktree opens it as a workspace in a new Ptah window.

Via MCP tool:

{
"tool": "ptah_git_worktree_list"
}

From the UI: right-click a worktree in the panel → Remove. Ptah prompts before removing and refuses to remove a worktree with uncommitted changes unless you explicitly override.

Via MCP tool:

{
"tool": "ptah_git_worktree_remove",
"arguments": {
"path": "../my-project-feature-x",
"force": false
}
}

A worktree-friendly folder layout that plays nicely with Ptah:

~/code/
├── my-project/ # Main worktree (clone root)
├── my-project-feature-x/ # Worktree: feature/x
├── my-project-review-123/ # Worktree: pr-123
└── my-project-hotfix/ # Worktree: hotfix/urgent

Ptah detects that all four folders share the same git repo and groups them in the worktree panel, regardless of which one you opened first.