vcspull worktree¶
The vcspull worktree command manages git worktrees declaratively from your
vcspull configuration. Instead of manually running git worktree add for each
branch or tag, you declare the desired worktrees in YAML and let vcspull
create, update, and prune them.
Command¶
Usage¶
usage: vcspull worktree [-h] [--trust-project] [--no-project] {list,sync,prune} ...
Options¶
Choose a subcommand for details:
vcspull worktree list — show configured worktrees and their status
vcspull worktree sync — create or update worktrees
vcspull worktree prune — remove worktrees not in configuration
Configuration¶
Worktrees are configured as a list under a repository entry. Each worktree
requires a dir (relative to workspace root or absolute) and exactly one
ref type: tag, branch, commit, or native rev.
~/code/:
myproject:
repo: "git+https://github.com/myorg/myproject.git"
worktrees:
# Pin a stable release (detached HEAD)
- dir: "../myproject-v2.0"
tag: "v2.0.0"
lock: true
lock_reason: "production reference"
# Track a development branch (updatable)
- dir: "../myproject-dev"
branch: "develop"
# Pin a specific commit (detached HEAD)
- dir: "../myproject-bisect"
commit: "abc1234"
Fields¶
Field |
Required |
Description |
|---|---|---|
|
yes |
Worktree path (relative to workspace root or absolute) |
|
one of |
Tag to checkout (creates detached HEAD) |
|
one of |
Branch to follow with fast-forward updates |
|
one of |
Commit SHA to checkout (creates detached HEAD) |
|
one of |
Native revision expression; attachment follows its resolved kind |
|
no |
Fetch source for a branch target |
|
no |
Drift and dirty policies described in vcspull worktree sync |
|
no |
Keep the resolved target detached, including a branch |
|
no |
Lock the worktree to prevent accidental removal |
|
no |
Reason for locking (implies |
Exactly one of tag, branch, commit, or rev must be specified per entry.
Worktrees inherit the parent repository’s Git transport options and remotes.
Integration with vcspull sync¶
The vcspull sync command can sync worktrees alongside
repositories using the --include-worktrees flag:
$ vcspull sync --include-worktrees '*'
Preview the combined operation:
$ vcspull sync --include-worktrees --dry-run '*'
This first syncs (clones/updates) the repository itself, then processes its configured worktrees.
JSON output¶
All subcommands support --json for structured output:
$ vcspull worktree list --json 'myproject'
Each worktree entry emits:
{
"reason": "worktree",
"worktree_path": "~/code/myproject-v2.0",
"ref_type": "tag",
"ref_value": "v2.0.0",
"action": "unchanged",
"exists": true,
"is_dirty": false,
"detail": "already at configured target",
"error": null,
"position": {
"revision": "3b8a1f2c9d0e4b5a6c7d8e9f0a1b2c3d4e5f6a7b",
"ref_name": "3b8a1f2c9d0e4b5a6c7d8e9f0a1b2c3d4e5f6a7b",
"ref_kind": "commit",
"follows": false,
"mixed": false,
"switched": false
},
"target_position": {
"revision": "3b8a1f2c9d0e4b5a6c7d8e9f0a1b2c3d4e5f6a7b",
"ref_name": "v2.0.0",
"ref_kind": "tag",
"follows": false,
"mixed": false,
"switched": false
},
"drifted": false
}
NDJSON output¶
Stream events line-by-line with --ndjson:
$ vcspull worktree list --ndjson 'myproject'
Each line is a self-contained JSON object, suitable for piping to jq or log aggregation.
Safety¶
vcspull refuses to touch work it could destroy:
Dirty policy governs updates. Updates abort on local changes by default.
Configure sync.dirty: preserve to retain and restore them, or configure
discard and pass --yes to authorize their removal. See
vcspull worktree sync for recovery output and drift policy. Worktree
pruning still refuses dirty checkouts.
Unknown refs stop creation. vcspull worktree list and --dry-run
inspect local metadata only, reporting unfetched refs as errors (✗) without
contacting remotes. vcspull worktree sync fetches configured remotes before
creating missing worktrees or updating branches, and reports an error (✗) if
the target still cannot be resolved.
Locks guard against removal. Worktrees created with lock: true or
lock_reason are locked via git worktree lock, preventing accidental
removal with git worktree remove.
Pattern filtering¶
Filter which repositories are processed using fnmatch-style patterns:
$ vcspull worktree list 'django*'
$ vcspull worktree sync 'myproject' 'another-repo'
Use '*' to match all repositories with worktrees configured.
Workspace filtering¶
Filter by workspace root directory:
$ vcspull worktree list --workspace ~/code/
Configuration file selection¶
By default, worktree subcommands resolve the active
configuration scopes. Specify a single configuration file
with --file (-f), skip ancestor project files with --no-project
(VCSPULL_NO_PROJECT=1), or authorize escaping project files without prompting
with --trust-project (VCSPULL_YES=1):
$ vcspull worktree list --file ~/projects/.vcspull.yaml
$ vcspull --no-project worktree list
Color output¶
Control colored output with --color:
--color auto(default): Use colors if outputting to a terminal--color always: Always use colors--color never: Never use colors
The NO_COLOR environment variable is also
respected.
Use cases¶
LLM / agentic workflows¶
Clone a repository trunk and pin multiple release tags for reference:
~/code/:
cpython:
repo: "git+https://github.com/python/cpython.git"
worktrees:
- dir: "../cpython-3.12"
tag: "v3.12.0"
- dir: "../cpython-3.13"
tag: "v3.13.0"
This gives agents read-only snapshots of specific versions alongside the main checkout.
Parallel development across branches¶
Work on multiple feature branches without switching:
~/code/:
webapp:
repo: "git+https://github.com/myorg/webapp.git"
worktrees:
- dir: "../webapp-feature-auth"
branch: "feature/auth"
- dir: "../webapp-feature-billing"
branch: "feature/billing"
Maintaining versioned reference copies¶
Lock stable releases to prevent accidental modification:
~/code/:
library:
repo: "git+https://github.com/myorg/library.git"
worktrees:
- dir: "../library-v1"
tag: "v1.0.0"
lock: true
lock_reason: "legacy API reference"
- dir: "../library-v2"
tag: "v2.0.0"
lock: true
lock_reason: "current stable reference"