Slide 39 / 55
Slide 39

Transcript

Creating a git worktree is straightforward. The basic command is: git worktree add, followed by a path and a branch name.

Let's say you're in your main repository directory and you want to create worktrees for parallel development. Here's how you'd do it.

First, create a new branch and worktree for a refactoring task: git worktree add ../myproject-refactor refactoring-branch

This creates a new directory called myproject-refactor one level up from your current repository, checks out a new branch called refactoring-branch, and sets up the worktree linkage.

Second, create another for feature development: git worktree add ../myproject-feature feature-branch

And a third for performance optimizations: git worktree add ../myproject-optimization optimization-branch

Now you have three separate directories, each with a different branch checked out, but they all share the same git repository. You can open a separate Claude Code session in each directory, and each session can work independently on its specialized task.

When you're done with a worktree, you can remove it with: git worktree remove ../myproject-refactor

Or if you want to see all your active worktrees: git worktree list

This shows you every worktree, which branch it has checked out, and where it's located. It's perfect for managing multiple parallel Claude Code sessions on a complex brownfield codebase.