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.
Video coming soon.
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.
About this article and its sources
Run this example in a new temporary folder. Packages, private configuration and running servers need their own setup in each worktree.
