# Use Git worktrees with Claude and Codex

Give each coding session its own folder and branch. Try it with a small website, compare two landing pages, and bring the version you like back into the main project.

[HTML](https://lukejbyrne.com/library/guides/ld_irvflxra/)
Content language: en
Author: Luke Byrne
Video published: null
Guide published: 2026-11-14

[Watch the video](https://www.youtube.com/watch?v=ld_IRvFLXRA)
Video language: English

- [Get the copyable commands and example edits (ZIP)](https://lukejbyrne.com/library/downloads/git-worktrees.zip)

[Complete guide](https://lukejbyrne.com/library/guides/drdaryw5q18/index.md)

## 1. Start a practice project

Open Terminal on macOS or Git Bash. The first block in the download creates a new temporary folder. It gives this practice repo its own author name and email so your usual Git settings stay untouched. Keep this terminal open.

## 2. Give each job a folder

The example makes landing-claude and landing-codex from the same commit. Each folder has its own checked-out branch and files. Both share the same commit history. Open Claude Code in one folder and Codex in the other. Ask each to change the headline in index.html. You can use the sample edits in the download to try this without either agent.

## 3. Compare the two edits

Commit each change on its own branch. From the main folder, run git diff landing-claude landing-codex -- index.html. That shows exactly how the page differs. You can also open both copies in a browser.

## 4. Keep the version you want

In the example you pick Claude’s headline: git merge --ff-only landing-claude. Codex’s version stays on its branch. If you like pieces of both versions, edit the result deliberately and review it before committing. Two designs changing the same lines can conflict.

## The takeaway

When a job is finished, list your worktrees and check for uncommitted, untracked and ignored files before removing that specific folder. The download shows the checks. Leave a folder in place if it contains anything you still need.

## Workflow resources

- [git-scm.com](https://git-scm.com/docs/git-worktree)

## Sources and limitations

Run this example in a new temporary folder. Packages, private configuration and running servers need their own setup in each worktree.

[Original video](https://www.youtube.com/watch?v=ld_IRvFLXRA)
