Configure
Worktree Init
Repo-local bootstrap for newly created managed worktrees.
Worktree init is a repo-local bootstrap step for gg_team add mode when gg creates a new
named managed worktree.
Script path
gg looks for exactly:
.agents/gg/worktree-init.sh
The script is resolved from the newly created worktree checkout.
When gg runs it
Worktree init runs only when:
- the operation is add mode;
worktree_nameis present; and- the managed-worktree control plane creates a new owner worktree.
It does not run when worktree_name is omitted, when an existing named worktree is reused, or
when the new member inherits a managed-worktree association as a consumer.
Named worktrees are created or reused automatically. Callers do not choose a separate reuse mode.
Execution contract
- gg executes
./.agents/gg/worktree-init.shsynchronously. - The process cwd is the new worktree root.
- A missing script is a no-op.
- Spawn failure or a non-zero exit blocks member creation before session creation.
- gg performs best-effort rollback of the in-flight branch/worktree after a bootstrap failure.
Hooks vs worktree init
pre_teammate_addhooks run before native worktree creation in the source session cwd.- Worktree init runs after creation in the new worktree cwd.
- The Add Agent pre-hook checkbox controls only Team Hooks; it does not disable worktree init.
Branch-specific behavior
The new checkout controls which script content runs. An untracked script present only in another checkout is not copied automatically.