gastownhall/beads · error
--merged-into object ID %q does not resolve to a commit: %w
Error message
--merged-into object ID %q does not resolve to a commit: %w
What it means
After ref matching fails and the selector is treated as a full object ID, bd calls `resolveWorktreeCommitOID` to confirm it points at a commit. If `git rev-parse` fails or the object is not a commit, this wrapped error reports both the selector and the underlying git error.
Source
Thrown at cmd/bd/worktree_cmd.go:1745
return pinnedWorktreeComparator{}, fmt.Errorf(
"--merged-into value %q is ambiguous; use a full ref name or a non-ref full object ID (matches: %s)",
selector,
strings.Join(matches, ", "),
)
}
if len(matches) == 1 {
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
}
View on GitHub (pinned to 71377f2769)
Solutions
- Verify with `git cat-file -t <oid>` that the object exists and is a `commit`
- Copy the OID again with `git rev-parse <ref>` from the same repository
- Use a branch/ref name instead of a raw OID
Example fix
// before bd worktree remove --merged-into 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # a tree // after bd worktree remove --merged-into $(git rev-parse refs/heads/main) # a commit
Defensive patterns
Strategy: validation
Validate before calling
// shell pre-check type=$(git cat-file -t "$OID" 2>/dev/null || true) [ "$type" = "commit" ] || echo "$OID is not a commit (got: $type)"
Try / catch
if err := runBd(); err != nil {
if strings.Contains(err.Error(), "does not resolve to a commit") {
// fall back to resolving a ref name instead of a raw OID
}
} Prevention
- Generate OIDs with `git rev-parse <ref>` in the same repository
- Confirm with `git cat-file -t` that the object is a commit
- Prefer ref names over raw OIDs in scripts
When it happens
Trigger: `--merged-into <full-oid>` where the OID does not exist in the repository, is malformed, or resolves to a non-commit object (tree, blob, tag object peeled to nothing).
Common situations: Copying an OID from a different repository; passing a tree or blob hash instead of a commit hash; truncated hash that was mistakenly assumed full-length; object pruned by `git gc`.
Related errors
- --merged-into object ID %q is the target HEAD itself; use a
- comparison ref %q does not resolve to a commit: %w
- auto-export: git add failed: %w
- failed to read .gitignore: %w
- failed to write .gitignore: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/57954348c1e52be3.
Report an issue: GitHub.