Git worktrees and parallel coding tasks

Isolate every agent task in its own worktree

Editing directly on main risks mixing half-finished agent changes with your own work. A git worktree checks out a second branch into a separate folder while sharing the same git history.

You can run one PraisonAI Code session on a bugfix worktree and a second session on a docs or refactor worktree at the same time with zero branch conflicts.

Example

# Create an isolated worktree for an agent task
git worktree add ../wt-fix-billing -b fix/billing-rounding main

# Run praisonai code strictly inside the isolated worktree
cd ../wt-fix-billing && praisonai code "Fix rounding in billing.py and add a unit test"

Example explained

  • git worktree add ../wt-fix-billing -b fix/billing-rounding main — Creates a clean, isolated working directory on a new branch without touching your main checkout.
  • cd ../wt-fix-billing && praisonai code … — Scopes the coding agent entirely to the feature branch directory.

Merge or discard cleanly when done

If the agent's patch passes tests, push the branch and open a PR. If you dislike the approach, delete the worktree in one command — main stays untouched.

Example

# Inspect active worktrees
git worktree list

# Remove a finished or discarded worktree cleanly
git worktree remove ../wt-fix-billing

Example explained

  • git worktree list — Shows every active isolated workspace and its checked-out branch.
  • git worktree remove — Cleans up the temporary directory once the branch is merged or abandoned.

Common pitfall: using git stash across worktrees

Git stashes are shared globally across all worktrees of a repo. Commit work-in-progress to your worktree branch instead of running git stash so parallel agents never pop each other's changes.

Reference: documentation