{"record":{"id":"99dab115e2043649","repo":"gastownhall/beads","slug":"merged-into-value-q-does-not-name-an-existing-u","errorCode":null,"errorMessage":"--merged-into value %q does not name an existing unambiguous ref","messagePattern":"--merged-into value %q does not name an existing unambiguous ref","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/worktree_cmd.go","lineNumber":1737,"sourceCode":"\t}\n\thashLength, err := repositoryObjectIDLength(ctx, git, executionRoot)\n\tif err != nil {\n\t\treturn pinnedWorktreeComparator{}, err\n\t}\n\tfullOID := isHexObjectID(selector, hashLength)\n\n\tif len(matches) > 1 || fullOID && len(matches) > 0 {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\n\t\t\t\"--merged-into value %q is ambiguous; use a full ref name or a non-ref full object ID (matches: %s)\",\n\t\t\tselector,\n\t\t\tstrings.Join(matches, \", \"),\n\t\t)\n\t}\n\tif len(matches) == 1 {\n\t\treturn pinWorktreeComparatorRef(ctx, git, executionRoot, target, selector, matches[0], true)\n\t}\n\tif !fullOID {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\n\t\t\t\"--merged-into value %q does not name an existing unambiguous ref\",\n\t\t\tselector,\n\t\t)\n\t}\n\n\toid, err := resolveWorktreeCommitOID(ctx, git, executionRoot, selector)\n\tif err != nil {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\n\t\t\t\"--merged-into object ID %q does not resolve to a commit: %w\",\n\t\t\tselector,\n\t\t\terr,\n\t\t)\n\t}\n\tif oid == target.headOID {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\n\t\t\t\"--merged-into object ID %q is the target HEAD itself; use a ref or descendant commit that independently proves containment\",\n\t\t\tselector,\n\t\t)","sourceCodeStart":1719,"sourceCodeEnd":1755,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/worktree_cmd.go#L1719-L1755","documentation":"When resolving a `--merged-into` selector into a pinned worktree comparator, bd first tries to match it against candidate refs. If exactly one match exists the ref is pinned; if no (or multiple) matches exist and the selector is not already a full-length hex object ID, this error is thrown because the selector does not name one existing, unambiguous ref.","triggerScenarios":"Passing `bd worktree remove --merged-into <selector>` where the selector matches zero candidate refs (typo, deleted branch) or matches more than one ref (e.g. `origin/foo` and `refs/heads/foo`), and the selector is not a full OID.","commonSituations":"Typos in branch names; ambiguous short names matching both a local and a remote-tracking ref; the merged-into branch was deleted after the merge; using a partial/abbreviated OID shorter than the full hash.","solutions":["Use the fully qualified ref name, e.g. `refs/heads/main` or `origin/main`, so the match is unambiguous","Run `git for-each-ref` and confirm exactly one ref corresponds to your selector","Pass the full 40/64-character commit OID instead of a ref name","Check for typos and confirm the branch still exists in the repository"],"exampleFix":"// before\nbd worktree remove --merged-into feature-x\n// after\nbd worktree remove --merged-into refs/heads/feature-x","handlingStrategy":"validation","validationCode":"// shell pre-check: exactly one ref matches\ncount=$(git for-each-ref --format='%(refname)' -- \"refs/heads/${SEL}\" \"refs/remotes/${SEL}\" | wc -l)\n[ \"$count\" -eq 1 ] || echo \"ambiguous or missing: $SEL\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass fully qualified refs (refs/heads/...) to --merged-into","Check `git for-each-ref` output before scripting the command","Avoid abbreviated OIDs; use the full hash"],"tags":["git","cli","ref-resolution","ambiguity"],"backgroundTag":"ambiguous-git-ref","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}