Run parallel sessions with worktrees changedworktrees
Nearest release: v2.1.233, published 7 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+18added
Lines−3removed
From line
142
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits34to this page, all time
The whole hunk
from line 142, old and new numbered
/
from line 142
142142
143143### Branch from a pull request
144144
145To branch from a specific pull request, pass `--worktree` the PR number prefixed with `#`, or a full GitHub pull request URL. Claude Code fetches `pull/<number>/head` from `origin` and creates the worktree at `.claude/worktrees/pr-<number>`. Quote the argument so your shell doesn't treat `#` as the start of a comment:
145To branch from a specific pull request or merge request, pass `--worktree` the number prefixed with `#`, a GitHub pull request URL, or a GitLab merge request URL such as `https://gitlab.com/group/repo/-/merge_requests/123`. Claude Code fetches that change's head commit from `origin` and creates the worktree at `.claude/worktrees/pr-<number>`. Quote the argument so your shell doesn't treat `#` as the start of a comment:
146146
147147```bash theme={null}
148148claude --worktree "#1234"
149149```
150150
151Claude Code reads only the number from the URL. It always fetches from your repository's `origin` remote, and picks the fetch path by `origin`'s host:
152
153* **github.com**: fetches `pull/<number>/head`
154* **gitlab.com**: fetches `merge-requests/<number>/head`
155* **GitHub Enterprise, self-managed GitLab, or any other host**: tries `pull/<number>/head` first, then `merge-requests/<number>/head`
156
157Before v2.1.233, Claude Code accepted only `#<number>` and GitHub-style pull request URLs for `--worktree`, and always fetched `pull/<number>/head`.
158
151159### Copy gitignored files into worktrees
152160
153161A worktree is a fresh checkout, so untracked files like `.env` or `.env.local` from your main repository are not present. To copy them automatically when Claude creates a worktree, add a `.worktreeinclude` file to your project root.
from line 180
172180
173181* It has no uncommitted changes or untracked files.
174182* It is still on the branch Claude Code created for it.
175* It has no commits of its own, or its pull request was merged and its remote branch deleted.
183* It has no commits of its own, or its pull request or merge request was merged and its remote branch deleted.
176184
177185Claude Code detects the merged case from git state alone: the remote branch the worktree pushed to no longer exists, and every commit in the worktree is already on the default branch.
178186
179Anything else reopens at the old tip: a worktree that fails any of the conditions, one whose state can't be verified, and any reuse when `worktree.baseRef` is `"head"` or the name is a pull request number. Before v2.1.208, a reused name always reopened the old worktree at its old tip.
187In every other case, Claude Code reopens the worktree at its old tip:
188
189* The worktree fails any of the conditions.
190* Claude Code can't verify the worktree's state.
191* `worktree.baseRef` is `"head"`.
192* The name is a pull request or merge request reference.
193
194Before v2.1.208, when you reused a name, Claude Code always reopened the old worktree at its old tip.
180195
181196### Replace worktree creation with a hook
182197
No line in this hunk matches that.