gastownhall/beads · error

git push (delete %s) failed: %s: %w

Error message

git push (delete %s) failed: %s: %w

What it means

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.

Source

Thrown at cmd/bd/dolt_remote_reset_data.go:151

		}
	}
	return refs, nil
}

// deleteGitDoltDataRefs deletes refs on the git remote at gitURL. Git
// client-side hooks are disabled for the push, same as bd's other internal
// git invocations (GH#3724 class: a user's templated pre-push hook must not
// break — or observe — bd's data-plane plumbing).
func deleteGitDoltDataRefs(ctx context.Context, gitURL string, refs []string) error {
	args := []string{"push", gitURL}
	for _, ref := range refs {
		args = append(args, ":"+ref)
	}
	cmd := exec.CommandContext(ctx, "git", args...) // #nosec G204 -- URL from configured remote, fixed refspecs
	cmd.Env = envWithNoGitHooks()
	out, err := cmd.CombinedOutput()
	if err != nil {
		return fmt.Errorf("git push (delete %s) failed: %s: %w", strings.Join(refs, ", "), strings.TrimSpace(string(out)), err)
	}
	return nil
}

// envWithNoGitHooks returns the current environment with git client-side
// hooks disabled via GIT_CONFIG_PARAMETERS, preserving any parameters the
// caller already set (mirrors applyNoGitHooksToCmd in internal/storage/dolt).
func envWithNoGitHooks() []string {
	base := os.Environ()
	merged := githooksenv.AppendParameter(githooksenv.Extract(base), githooksenv.NoHooksParam)
	env := make([]string, 0, len(base)+1)
	prefix := githooksenv.ParametersEnv + "="
	for _, e := range base {
		if !strings.HasPrefix(e, prefix) {
			env = append(env, e)
		}
	}
	return append(env, prefix+merged)

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the git output in the error for the server's refusal reason (e.g. 'protected ref', 'permission denied')
  2. Grant the credential write/delete access on the remote, or unprotect refs/dolt/* in the host's settings
  3. Test manually with 'git push <url> :<ref>' to reproduce outside bd
  4. Confirm the remote URL points at a repo you administer before deleting Dolt data

Example fix

// before
token scope: repo:read  -> push (delete refs/dolt/data) rejected
// after
regenerate token with repo:write scope, update credential helper, retry bd dolt remote reset-data
Defensive patterns

Strategy: try-catch

Validate before calling

// check delete permission before destructive reset
if err := exec.Command("git", "push", "--dry-run", url, ":"+gitDoltDataRef).Run(); err != nil {
    return errors.New("remote refuses ref deletion; check permissions/protected refs")
}

Try / catch

if err := deleteGitDoltDataRefs(ctx, url, refs); err != nil {
    // parse wrapped git output for 'protected'/'denied' and instruct user to fix remote policy
    return fmt.Errorf("reset-data aborted; Dolt refs intact: %w", err)
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/e1798234d4d2295c. Report an issue: GitHub.