worktree add¶
Create a sibling Git worktree for a multi workspace.
Usage¶
Description¶
The worktree add command creates a Git worktree next to the current workspace root. 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 |
Sibling directory name for the new worktree |
Options¶
| Option | Description |
|---|---|
--branch BRANCH |
Branch name for the worktree. Defaults to NAME |
Behavior¶
- Checks that the root repo and sub-repos are clean.
- Creates a sibling root worktree on the target branch.
- 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.
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 sibling directory must not already exist.
- Transfer paths must be relative, gitignored, and inside the workspace.
- Existing transfer destinations are skipped.