beads/docs/cli-reference/worktree.md
Chris Sells de0200ff77 docs(emitter): Cobra-accurate usage lines, published global flags, MDX ESM guard
Three generated-content defects from the adversarial review, all
structurally invisible to the drift gate (generated-vs-generated):

- Usage lines now mirror Cobra's help template: a runnable command shows
  its UseLine, a command with subcommands shows '<path> [command]', both
  when both apply. Previously bare UseLine() stamped 'bd mol [flags]' on
  30 parent pages — a line the binary never prints.
- The generated CLI index publishes the Global Flags block; the binary
  prints it on every --help but no page carried it.
- docsmint neutralizes prose lines that Mintlify's prebuild would dedent
  into MDX ESM blocks (a line beginning 'export'/'import' outside a
  fence gets wrapped in a code span). This is why /cli-reference/mail
  returned HTTP 200 while rendering only a parse-error placeholder —
  reproduced, fixed, and covered by a planted-hazard test; fenced
  content stays verbatim.

Also rewords check-cli-docs-drift.sh's early-PASS message, which
asserted 'the supplied binary differs' as the cause when uncommitted
local edits produce the same result.

All 113 pages + docs/CLI_REFERENCE.md regenerated through the pipeline;
TDD'd in cmd/bd/help_all_test.go and tools/docsmint/docsmint_test.go.
Verified live: /cli-reference/mail renders real content, zero parse
errors; generate-cli-docs.sh --check, docsync, freshness, and
mint broken-links all pass on this tree.
2026-07-12 10:37:17 -07:00

114 lines
2.8 KiB
Markdown

---
title: "bd worktree"
description: "Manage git worktrees for parallel development"
---
{/* AUTO-GENERATED: do not edit manually */}
Generated from `bd help --doc worktree`.
Manage git worktrees with proper beads configuration.
Worktrees allow multiple working directories sharing the same git repository,
enabling parallel development (e.g., multiple agents or features).
Worktrees automatically share the same beads database as the main repository
via git common directory discovery — no manual redirect configuration needed.
Examples:
bd worktree create feature-auth # Create worktree
bd worktree create bugfix --branch fix-1 # Create with specific branch name
bd worktree list # List all worktrees
bd worktree remove feature-auth # Remove worktree (with safety checks)
bd worktree info # Show info about current worktree
```
bd worktree [command]
```
## bd worktree create
Create a git worktree for parallel development.
This command:
1. Creates a git worktree at ./&lt;name&gt; (or specified path)
2. Adds the worktree path to .gitignore (if inside repo root)
The worktree automatically shares the same beads database as the main
repository via git common directory discovery — no redirect file needed.
Examples:
bd worktree create feature-auth # Create at ./feature-auth
bd worktree create bugfix --branch fix-1 # Create with branch name
bd worktree create ../agents/worker-1 # Create at relative path
```
bd worktree create <name> [--branch=<branch>] [flags]
```
**Flags:**
```
--branch string Branch name for the worktree (default: same as name)
```
## bd worktree info
Show information about the current worktree.
If the current directory is in a git worktree, shows:
- Worktree path and name
- Branch
- Beads configuration (redirect or main)
- Main repository location
Examples:
bd worktree info # Show current worktree info
bd worktree info --json # JSON output
```
bd worktree info [flags]
```
## bd worktree list
List all git worktrees and their beads configuration state.
Shows each worktree with:
- Name (directory name)
- Path (full path)
- Branch
- Beads state: "redirect" (uses shared db), "shared" (is main), "none" (no beads)
Examples:
bd worktree list # List all worktrees
bd worktree list --json # JSON output
```
bd worktree list [flags]
```
## bd worktree remove
Remove a git worktree with safety checks.
Before removing, this command checks for:
- Uncommitted changes
- Unpushed commits
- Stashes
Use --force to skip safety checks (not recommended).
Examples:
bd worktree remove feature-auth # Remove with safety checks
bd worktree remove feature-auth --force # Skip safety checks
```
bd worktree remove <name> [flags]
```
**Flags:**
```
--force Skip safety checks
```