One change
Run parallel sessions with worktrees
worktrees
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.
worktrees Changed · +18 / -3 lines
from line 142
### Branch from a pull request -To 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: +To 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: ```bash theme={null} claude --worktree "#1234" ``` +Claude 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: + +* **github.com**: fetches `pull/<number>/head` +* **gitlab.com**: fetches `merge-requests/<number>/head` +* **GitHub Enterprise, self-managed GitLab, or any other host**: tries `pull/<number>/head` first, then `merge-requests/<number>/head` + +Before v2.1.233, Claude Code accepted only `#<number>` and GitHub-style pull request URLs for `--worktree`, and always fetched `pull/<number>/head`. + ### Copy gitignored files into worktrees A 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
* It has no uncommitted changes or untracked files. * It is still on the branch Claude Code created for it. -* It has no commits of its own, or its pull request was merged and its remote branch deleted. +* It has no commits of its own, or its pull request or merge request was merged and its remote branch deleted. Claude 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. -Anything 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. +In every other case, Claude Code reopens the worktree at its old tip: + +* The worktree fails any of the conditions. +* Claude Code can't verify the worktree's state. +* `worktree.baseRef` is `"head"`. +* The name is a pull request or merge request reference. + +Before v2.1.208, when you reused a name, Claude Code always reopened the old worktree at its old tip. ### Replace worktree creation with a hook