worktree add¶
Create an isolated Git worktree for a multi workspace.
Usage¶
Description¶
The worktree add command creates a Git worktree at <parent>/<workspace-dirname>-worktrees/NAME, a sibling -worktrees directory next to the current workspace root (created if missing). For example, running it from ~/code/my-workspace creates ~/code/my-workspace-worktrees/NAME. It then runs multi sync in the new worktree, checks sub-repos out to the worktree branch, and transfers configured gitignored local paths from the original workspace.
If --branch is omitted, NAME is used as the branch name.
Arguments¶
| Argument | Description |
|---|---|
NAME |
Directory name for the new worktree inside the <workspace-dirname>-worktrees sibling directory |
Options¶
| Option | Description |
|---|---|
--branch BRANCH |
Branch name for the worktree. Defaults to NAME |
Behavior¶
- Creates a root worktree on the target branch inside the
<workspace-dirname>-worktreessibling directory, creating that directory if needed. - Runs
multi syncin the new worktree to populate sub-repos and generated config. - Checks sub-repos out to the target branch, except repos with
fixedBranch. - Symlinks or copies configured gitignored paths from the original workspace.
Dirty working trees do not block this command: the worktree branches from a commit (HEAD or --base-ref) and the source working trees are never modified.
Examples¶
Use the worktree name as the branch¶
Use a custom branch name¶
Transfer ignored local files¶
{
"worktree": {
"symlink": [".env", ".venv"],
"copy": [".cursor/local.json"]
},
"repos": [
{
"url": "https://github.com/org/shared",
"fixedBranch": "main"
}
]
}
Requirements¶
- The command is not available in
monoRepomode. - The destination directory must not already exist.
- Transfer paths must be relative, gitignored, and inside the workspace.
- Existing transfer destinations are skipped.