Free developer tool

Free Git Worktree Command Builder

A git worktree is an extra working folder for the same repository, checked out on its own branch, so you can work on several branches at once without stashing or cloning. This builder writes the exact git worktree command for adding, listing, removing, pruning, moving, locking or repairing a worktree, explains what it does and lists the errors git may show. Parallel mode plans one worktree and branch per task for running AI coding agents side by side. Nothing runs on your machine until you paste it.

Command

git worktree add -b feature/fix-login ../myapp-wt/fix-login main

Creates the folder, creates the new branch from the start point, and checks it out there. Your current checkout is not touched.

Common errors and fixes

  • fatal: a branch named 'feature/x' already existsUse "Add worktree for an existing branch" instead. -B would reset the existing branch to the start point and can lose commits.
  • fatal: '../myapp-wt/x' already existsPick a new folder, or delete the old folder first. If Git still lists it, run git worktree remove on it.
  • fatal: '../myapp-wt/x' is a missing but already registered worktreeThe folder was deleted by hand but Git still tracks it. Run git worktree prune, then add it again.

Git worktree vs branch vs stash vs clone

Switch branches

One folder, one branch at a time. git switch needs a clean tree, so half-done work must be committed or stashed first.

Stash

Parks changes so you can switch. Fine for a quick hop; easy to forget, and builds and dev servers restart every time.

Worktree

One folder per branch, all sharing one .git history, so commits made in any worktree are visible in all. Each folder needs its own dependencies and .env.

Second clone

Fully separate copy with its own history and remotes. Uses more disk, and you must push and fetch to move commits between clones.

How to use the git worktree builder

  1. 1. Pick an action

    Choose add, list, remove, prune, move, lock, unlock or repair, or switch to Parallel AI agents mode.

  2. 2. Fill in the path and branch

    Enter the worktree folder, the branch name and the start point. The builder checks branch names against git naming rules and quotes paths with spaces.

  3. 3. Copy and run the command

    Copy the command and run it from inside your repository. Read the common errors list if git refuses.

  4. 4. Clean up when done

    Remove each worktree, delete its merged branch and prune stale records so git worktree list stays accurate.

Running parallel AI coding agents with worktrees

Two agents in one folder overwrite each other's files and confuse each other's test runs. Give each agent its own worktree and branch, start it inside that folder, and merge the branches one at a time after review. Keep the count small enough for your machine: each worktree runs its own install, build and dev server. Pick distinct dev server ports per worktree, and remove worktrees as soon as their branch is merged.

Git worktree FAQ

What is git worktree used for?

git worktree lets one repository have several working folders at once, each on its own branch. You can review a pull request, fix a bug or run a long test in one folder while your unfinished work stays untouched in another, without stashing or cloning again.

What is the difference between a git worktree and a branch?

A branch is a line of commits. A worktree is a folder where a branch is checked out. Without worktrees you have one folder and switch branches in it; with worktrees each branch can have its own folder, and all of them share one .git history.

How do I create a git worktree with a new branch?

Run git worktree add -b <new-branch> <path> <start-point>, for example git worktree add -b feature/login ../myapp-wt/login main. Git creates the folder, creates the branch from main and checks it out there.

How do I remove a git worktree?

Run git worktree remove <path> from any checkout of the repository. It refuses if the worktree has uncommitted or untracked changes; commit them or add --force. Then delete the branch with git branch -d <branch>. If you already deleted the folder by hand, run git worktree prune.

Why does git say a branch is already used by a worktree?

Git lets a branch be checked out in only one worktree at a time. Work in the worktree that already has it, which git worktree list shows, or create a new branch for the new worktree with -b.

How do I run several Claude Code or Codex agents in parallel?

Give each agent its own worktree and branch so they never edit the same files on disk. Create one worktree per task, start the agent inside each folder, review and merge each branch, then remove the worktrees. The parallel mode above writes those scripts for you.

Orchestrate parallel agents without the terminal juggling

Running one agent per worktree by hand means many terminals and scripts. Tornic runs deterministic multi-step workflows on the Claude Code, Codex or Cursor CLI you already pay for.

Explore Tornic

Related free tools