Leverage git worktree to parallelize work with Codex, Claude Code, etc.

Published: (February 18, 2026 at 06:31 AM EST)
3 min read
Source: Dev.to

Source: Dev.to

The problem

In a traditional Git repository you have:

  • The source code in a working directory, e.g. /Users/qlerebours/Projects/traveledmap.
  • A checked‑out branch, e.g. feat/my-main-feature.
  • The .git folder that contains the project history.

Switching branches changes the files in your current directory, which makes it difficult to run tools like Codex, Claude Code, etc., on multiple features at the same time. Cloning the project into a second folder is not ideal because it duplicates the (potentially large) .git folder.

git worktree

git worktree lets you attach multiple working directories to the same Git repository while keeping a single .git directory.

# Add a new worktree for a parallel task
git worktree add ../traveledmap-fix-wording fix/add-form-validations

After running the command the folder structure looks like this:

/Users/qlerebours/Projects/traveledmap/                     (branch feat/my-main-feature)
/Users/qlerebours/Projects/traveledmap-fix-add-form-validations/  (branch fix/add-form-validations)
  • A single .git folder lives in /Users/qlerebours/Projects/traveledmap/.
  • Each worktree uses its own branch.
  • Commits are visible instantly across all worktrees.

This setup lets your code assistant work on two features in parallel.

Using git worktree with AI development assistants

  1. Start a new conversation in Codex (or Claude Code) and choose Worktree and from develop as the base for the new branch.

  2. When you send the prompt, Codex announces that it’s creating the worktree. You can verify it with:

    git worktree list
  3. The worktree will appear under a path similar to /Users/qlerebours/.codex/worktrees//traveledmap.

Test the changes

If you want to test the changes without pulling them locally:

  1. Enter the worktree folder.

  2. Since the worktree starts from the develop branch, set up the environment:

    cp .env.example .env
    pnpm i
  3. Run the project:

    pnpm run dev
  4. If new changes are needed, Codex will add them to the existing worktree so you can test again.

Taking control of the changes

You have several options to continue work locally:

  • Open the worktree folder in your preferred code editor and make the desired changes.
  • Use the “Hand off to local” button in the Codex conversation; this commits the changes to the repository.
  • Use the “Create a branch” button, which creates a new branch and pushes it, allowing you to open a PR directly.

Further reading

The full documentation for this workflow is available in the Codex docs.

Understanding git worktree opens the door to efficient collaboration with AI development assistants. If you have questions, feel free to reach out by email or on LinkedIn.

0 views
Back to Blog

Related posts

Read more »

OpenClaw Is Unsafe By Design

OpenClaw Is Unsafe By Design The Cline Supply‑Chain Attack Feb 17 A popular VS Code extension, Cline, was compromised. The attack chain illustrates several AI‑...