gastownhall/beads · error
--merged-into object ID
Error message
--merged-into object ID %q is the target HEAD itself; use a ref or descendant commit that independently proves containment
What it means
The `--merged-into` comparator must independently prove that the worktree's HEAD is contained in (i.e. is an ancestor of) some other commit. If the resolved OID equals the target worktree's HEAD OID, no such independent proof exists, so bd rejects the selector with this error.
Solutions
- Pass a ref or commit that is a strict descendant of the worktree HEAD, e.g. the branch it was merged into (`refs/heads/main`)
- Run `git log --oneline` to pick a commit after the worktree's HEAD
- Use the merge-target branch name rather than the worktree's own HEAD
Example fix
// before bd worktree remove --merged-into $(git -C ../wt rev-parse HEAD) // after bd worktree remove --merged-into refs/heads/main
Defensive patterns
Strategy: validation
Validate before calling
// shell pre-check: OID must differ from the worktree HEAD wt_head=$(git -C "$WORKTREE" rev-parse HEAD) [ "$OID" != "$wt_head" ] || echo "--merged-into equals target HEAD; pick a descendant"
Prevention
- Never pass the worktree's own HEAD or its checked-out branch as --merged-into
- Pick the merge-target branch (e.g. main) as the comparator
- Verify ancestry with `git merge-base --is-ancestor <head> <selector>` first
When it happens
Trigger: Passing `--merged-into <oid>` where the full resolved OID is exactly the target worktree's current `headOID`.
Common situations: Copy-pasting `git rev-parse HEAD` from inside the target worktree; scripting `--merged-into $(git rev-parse <branch>)` where the branch is checked out at HEAD in that worktree.
Related errors
- comparison ref does not resolve to a commit
- --merged-into object ID
- auto-export: git add failed
- comparison ref resolves through a worktree-local ref…
- comparison ref resolves to the target worktree branch and…
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/fade04d4a20aae47.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/bd/worktree_cmd.go:1752
return pinWorktreeComparatorRef(ctx, git, executionRoot, target, selector, matches[0], true)
}
if !fullOID {
return pinnedWorktreeComparator{}, fmt.Errorf(
"--merged-into value %q does not name an existing unambiguous ref",
selector,
)
}
oid, err := resolveWorktreeCommitOID(ctx, git, executionRoot, selector)
if err != nil {
return pinnedWorktreeComparator{}, fmt.Errorf(
"--merged-into object ID %q does not resolve to a commit: %w",
selector,
err,
)
}
if oid == target.headOID {
return pinnedWorktreeComparator{}, fmt.Errorf(
"--merged-into object ID %q is the target HEAD itself; use a ref or descendant commit that independently proves containment",
selector,
)
}
return pinnedWorktreeComparator{
selector: selector,
explicit: true,
oid: oid,
}, nil
}
func gitRefNameIsValid(
ctx context.Context,
git *worktreeRemovalGit,
executionRoot string,
ref string,
allowOneLevel bool,
) (bool, error) {View on GitHub (pinned to 71377f2769)