{"record":{"id":"e1798234d4d2295c","repo":"gastownhall/beads","slug":"git-push-delete-s-failed-s-w","errorCode":null,"errorMessage":"git push (delete %s) failed: %s: %w","messagePattern":"git push \\(delete (.+?)\\) failed: (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/dolt_remote_reset_data.go","lineNumber":151,"sourceCode":"\t\t}\n\t}\n\treturn refs, nil\n}\n\n// deleteGitDoltDataRefs deletes refs on the git remote at gitURL. Git\n// client-side hooks are disabled for the push, same as bd's other internal\n// git invocations (GH#3724 class: a user's templated pre-push hook must not\n// break — or observe — bd's data-plane plumbing).\nfunc deleteGitDoltDataRefs(ctx context.Context, gitURL string, refs []string) error {\n\targs := []string{\"push\", gitURL}\n\tfor _, ref := range refs {\n\t\targs = append(args, \":\"+ref)\n\t}\n\tcmd := exec.CommandContext(ctx, \"git\", args...) // #nosec G204 -- URL from configured remote, fixed refspecs\n\tcmd.Env = envWithNoGitHooks()\n\tout, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"git push (delete %s) failed: %s: %w\", strings.Join(refs, \", \"), strings.TrimSpace(string(out)), err)\n\t}\n\treturn nil\n}\n\n// envWithNoGitHooks returns the current environment with git client-side\n// hooks disabled via GIT_CONFIG_PARAMETERS, preserving any parameters the\n// caller already set (mirrors applyNoGitHooksToCmd in internal/storage/dolt).\nfunc envWithNoGitHooks() []string {\n\tbase := os.Environ()\n\tmerged := githooksenv.AppendParameter(githooksenv.Extract(base), githooksenv.NoHooksParam)\n\tenv := make([]string, 0, len(base)+1)\n\tprefix := githooksenv.ParametersEnv + \"=\"\n\tfor _, e := range base {\n\t\tif !strings.HasPrefix(e, prefix) {\n\t\t\tenv = append(env, e)\n\t\t}\n\t}\n\treturn append(env, prefix+merged)","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/dolt_remote_reset_data.go#L133-L169","documentation":"deleteGitDoltDataRefs pushes empty refspecs (':ref') to delete Dolt data refs on a git-backed remote and wraps git's failure into this error, including the refs being deleted and git's combined output. Common causes are missing push permission (force-push/delete rights), authentication failure, or a read-only remote. The command runs with client-side hooks disabled via envWithNoGitHooks.","triggerScenarios":"bd dolt remote reset-data determining that git-backed Dolt data refs exist and attempting to delete them, but 'git push <url> :refs/dolt/... ' fails — e.g. the remote rejects ref deletion, credentials lack write access, or the remote rejects non-fast-forward/delete via policy (protected refs).","commonSituations":"Hosted git server protecting refs/dolt/* from deletion; CI token with read-only scope; SSH key authorized for read but not write; server-side pre-receive hook blocking deletes despite client hooks being disabled.","solutions":["Check the git output in the error for the server's refusal reason (e.g. 'protected ref', 'permission denied')","Grant the credential write/delete access on the remote, or unprotect refs/dolt/* in the host's settings","Test manually with 'git push <url> :<ref>' to reproduce outside bd","Confirm the remote URL points at a repo you administer before deleting Dolt data"],"exampleFix":"// before\ntoken scope: repo:read  -> push (delete refs/dolt/data) rejected\n// after\nregenerate token with repo:write scope, update credential helper, retry bd dolt remote reset-data","handlingStrategy":"try-catch","validationCode":"// check delete permission before destructive reset\nif err := exec.Command(\"git\", \"push\", \"--dry-run\", url, \":\"+gitDoltDataRef).Run(); err != nil {\n    return errors.New(\"remote refuses ref deletion; check permissions/protected refs\")\n}","typeGuard":null,"tryCatchPattern":"if err := deleteGitDoltDataRefs(ctx, url, refs); err != nil {\n    // parse wrapped git output for 'protected'/'denied' and instruct user to fix remote policy\n    return fmt.Errorf(\"reset-data aborted; Dolt refs intact: %w\", err)\n}","preventionTips":["Use credentials with write/delete scope for the git-backed remote","Unprotect refs/dolt/* on the git host before running reset-data","Dry-run the ref deletion with git push --dry-run before automating it"],"tags":["git","push","remote","permissions","subprocess"],"backgroundTag":"git-push-delete-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}