Copilot CLI worktree: --worktree, /new worktree, /fork worktree, and what nobody cleans up
- copilot
- coding-agents
- agent-ops
Copilot CLI worktree support is built in. Start a session with copilot --worktree or -w. GitHub Copilot CLI then creates or reuses a Git worktree under <repo>.worktrees/, then runs the session inside it. In a running session, /new worktree opens an empty session in a new worktree. /fork worktree copies the current conversation into one. This post is for people who already use worktrees in Claude Code or Codex. I don't run Copilot CLI. Everything below comes from the GitHub docs and the CLI changelog up to 1.0.109, read on 12 November 2026.
copilot --worktree # new session, auto-named branch
copilot --worktree=<BRANCH> # new session on a branch you name
# inside a session
/new worktree # empty session in a new worktree
/fork worktree # same conversation, new worktree
/move <BRANCH> # take uncommitted changes along
- Location.
<repo>.worktrees/by default. TheworktreePathTemplatesetting moves it. - Branch. A named branch. You pass the name or Copilot generates one.
- Base. Your current HEAD.
worktreeBaseRefcan switch it to the remote default branch. - Uncommitted changes.
/worktreeleaves them behind./movecarries them over. - Cleanup. The docs describe no command that removes a worktree. Git does that part.
The Claude Code side, with the review and merge workflow, is in Claude Code worktrees. Codex, with my own test, is in Codex worktree.
Does GitHub Copilot CLI support worktrees?
Yes. GitHub Copilot CLI has the -w / --worktree flag and four slash commands for Git worktrees. They are /new worktree, /fork worktree, /worktree and /move. The command reference lists all of them. The flag arrived as experimental in 1.0.64 on 23 June 2026. Since 1.0.85 it works without experimental mode.
A Git worktree is a second working directory of the same repository. It shares history with the main checkout. It has its own files and its own checked-out branch.
Where does copilot --worktree create the worktree?
By default in a folder named <repo>.worktrees/. The config reference says slashes in the branch name are flattened to dashes there. The docs don't say whether that folder sits next to the repo or inside it. The worktreePathTemplate setting changes the location, for example to ~/src/worktrees/{repo}/{branch}. It accepts {repoPath}, {repo}, {branch} and {branchSlug}.
The reference says --worktree will "create or reuse" a worktree. So a branch name you used before should reopen its checkout. I did not test that.
Which branch does a Copilot CLI worktree use?
A named branch, started from your current HEAD. Copilot CLI takes the name you pass. For copilot --worktree the reference says to "omit it to auto-generate a branch name". For /worktree and /move, it generates the name from the conversation. The worktreeBaseRef setting has two values. "head" is the default. "defaultBranch" starts new worktrees from the remote default branch instead. /fork worktree ignores the setting and always branches off HEAD.
The default changed in 1.0.79 on 10 August 2026. Before that, --worktree started from the remote default branch. Codex picks no branch at all. Claude Code starts from the remote default branch.
What happens to uncommitted changes in a Copilot CLI worktree?
It depends on the command. /worktree creates the new worktree and leaves uncommitted changes in the old one. /move takes them along into the new worktree. The two were split in 1.0.71 on 16 July 2026.
For copilot --worktree, the command reference says nothing about uncommitted changes. A new worktree starts from a commit. So I expect your edits to stay in the original checkout. Commit them first, or start a normal session and use /move. Version 1.0.109 adds one safety note. An interrupted --worktree checkout now stays on disk, with recovery steps that remind you to keep local changes.
How much isolation does a Copilot CLI worktree give?
Copilot CLI worktree isolation covers files and the branch. It does not cover saved permissions. The config reference says linked worktrees resolve to the main repository root. So they share saved tool permissions with the main worktree. A saved approval from the main checkout applies in every worktree of that repo.
Folder trust carries over too. The changelog says it persists across Git worktrees without a new prompt. To limit what commands can read, write or reach, turn on the Copilot CLI sandbox. That is a separate switch, covered in Copilot CLI sandbox.
Is a Copilot CLI worktree the same as a workspace?
No. A worktree is a separate Git checkout with its own branch. In the Copilot CLI docs, "workspace" mostly shows up as the IDE workspace that /ide connects to, or workspace MCP servers from .mcp.json. Those servers load from the working directory up to the Git root. In Git, a linked worktree has its own top-level folder, so I read that root as the worktree folder. So I think a worktree session reads the .mcp.json on its own branch. The docs don't say this directly.
How do I clean up Copilot CLI worktrees?
With Git. Neither the command reference nor the config reference describes a command that removes a worktree. I found none in the changelog either. Run git worktree list from the main checkout, then git worktree remove on the path.
git worktree list
git worktree remove <PATH>
git branch -d <BRANCH> # the branch stays after remove
The git worktree docs say remove refuses a worktree with modified or untracked files unless you add --force. git worktree prune clears records of folders you deleted by hand. Copilot CLI 1.0.109 does clean one thing. It deletes its search index cache for worktrees that no longer exist, which the changelog says could reach tens of gigabytes.
How does Copilot CLI compare with Claude Code and Codex worktrees?
Copilot CLI sits between the two. It names a branch like Claude Code. It starts from HEAD like Codex. The Claude Code column comes from the Claude Code worktrees docs, the Codex one from my own test.
| Copilot CLI 1.0.109 | Claude Code | Codex CLI 0.166.0 | |
|---|---|---|---|
| Flag | -w, --worktree[=NAME] | --worktree <name> or -w | --worktree |
| Location | <repo>.worktrees/ | .claude/worktrees/<name>/ | ~/.codex/worktrees/<hex>/<repo> |
| Branch | Named, given or generated | worktree-<name> | Detached HEAD |
| Base | HEAD, or remote default with worktreeBaseRef | Remote default, or HEAD with worktree.baseRef | Current HEAD commit |
| Uncommitted changes | /worktree leaves them, /move carries them | Starts from a commit | Not carried (my test) |
| Cleanup | None in the docs | Prompt on exit when the worktree has work | None in the CLI |
| Resume | /restart reopens the same worktree | claude --worktree <name> --resume | Not supported, use codex fork --worktree |
Frequently asked questions
Is there a Copilot CLI worktree mode?
Not a separate mode. Worktrees in Copilot CLI are a flag and slash commands, not a setting you switch on. Before 1.0.85 you had to enable experimental mode to use them. Now --worktree, /worktree and /move work in a normal session.
Can I resume a Copilot CLI session in its worktree?
Partly. The command reference says sessions started with -w or --worktree come back in the same worktree after /restart. But --worktree conflicts with --resume, --continue and --connect, so you can't combine them. The resume flags are in Copilot CLI resume.
Does Copilot CLI delete worktrees on exit?
The docs don't say it does. Assume the folder and the branch stay until you remove them with Git.
Did you test this?
No. Copilot CLI is not installed on my machine. This post is built from the GitHub docs and the changelog up to 1.0.109, read on 12 November 2026. Where I infer something, the text says so.
The verdict
I think Copilot CLI has the fullest set of worktree commands of the three CLIs I cover. I'd like /move in Claude Code. The weak spot is cleanup. Nothing in the docs removes a worktree, so run git worktree list every week. A worktree splits files, not permissions.
Sources, read on 12 November 2026: the Copilot CLI command reference and configuration directory reference, the Copilot CLI changelog up to 1.0.109, the git worktree docs and the Claude Code worktrees page. The Codex column is from my Codex worktree test.