Documentation
¶
Overview ¶
Package worktree creates ephemeral `git worktree` checkouts so concurrent agent workers can each mutate files without racing on one shared tree.
Usage:
wt, err := worktree.Create(repoRoot, "swarm-w0")
if err != nil { ... }
defer wt.Cleanup()
// wt.Path is a fresh working tree on a detached HEAD at the original ref.
The caller decides what to do with diverging worktrees on completion (merge, copy patches back, discard). This package only handles allocation + cleanup; it does not invent a merge policy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Worktree ¶
type Worktree struct {
Path string
// contains filtered or unexported fields
}
Worktree is one isolated checkout. Path is the working directory; the underlying branch is detached so commits there don't move the source repo's HEAD.
func Create ¶
Create allocates a new worktree rooted under the repo's standard `.git/worktrees` parent dir if available, falling back to a sibling directory of repoRoot. `label` is a short suffix used to name both the directory and the detached branch reference for easier debugging.
repoRoot must point inside a git repo. Returns an error if `git` is not on PATH or repoRoot is not a working tree.