Understanding Git Worktrees
Git worktrees allow you to check out multiple branches from the same repository at once, each in its own directory. Instead of switching branches and stashing changes, you work in separate directories that all share the same Git history.How Zenflow Uses Worktrees
When you create a task in Zenflow:- A new worktree is created at
.zenflow/tasks/{task_id} - A dedicated branch is created for that task
- Agents work in this isolated directory without affecting your main workspace
- Changes remain completely separate until you merge
Working with the IDE
Keep the agent and your editor aligned by following these patterns:Launch the right workspace
- Project ⋯ → Open in IDE opens your usual repo checkout
- Task ⋯ → Open in IDE opens that task’s
.zenflow/tasks/{task_id}worktree
Commit manual edits
Zenflow auto-commits each agent step. Manual IDE changes appear as uncommitted—use the Changes page to Commit or Discard them.
Worktree Lifecycle
| Event | What Happens |
|---|---|
| Task created | New worktree and branch created |
| Task running | Agent works in worktree directory |
| Task paused | Worktree preserved with current state |
| Task archived | Worktree cleaned up, branch optionally deleted |
Best Practices
Keep worktrees task-scoped
Keep worktrees task-scoped
Each task should have exactly one worktree. Don’t manually create additional worktrees inside
.zenflow/tasks/ or you’ll confuse Zenflow’s orchestration.Let Zenflow manage the lifecycle
Let Zenflow manage the lifecycle
Zenflow automatically creates worktrees when tasks start and cleans them up when tasks are archived or deleted. Manual worktree commands (
git worktree add/remove) inside Zenflow directories can break automation.Merge or archive promptly
Merge or archive promptly
Worktrees consume disk space. After merging a task’s changes, archive or delete the task so Zenflow can clean up the worktree directory.
Choose source branches carefully
Choose source branches carefully
When creating a task, the “workspace” dropdown lets you choose which branch to base your work on. This determines what code your task starts with—usually
main or develop.Common Issues
Troubleshooting
If a task workspace becomes corrupted or won’t open:- Try archiving and recreating the task
- Check that you have sufficient disk space
- Verify the source branch still exists
- Look for error messages in the task’s chat telemetry
Next Steps
Tracking Changes
Monitor agent modifications in real-time
Tasks Overview
Full guide to creating and managing tasks