gastownhall/beads · error

remote target %s is non-empty but is neither a bare git repo

Error message

remote target %s is non-empty but is neither a bare git repository nor a Dolt file store (no manifest); refusing to clear it

What it means

This safety error fires when the local path of a file-backed Dolt remote is non-empty but lacks both a bare-git structure and a Dolt manifest file. classifyResetDataRemote refuses to clear it because reset-data cannot tell whether the contents are Dolt data or unrelated user files that would be destroyed.

Source

Thrown at cmd/bd/dolt_remote_reset_data.go:81

		return resetDataUnsupported, nil
	}
	entries, err := os.ReadDir(path)
	if os.IsNotExist(err) {
		return resetDataFileAbsent, nil
	}
	if err != nil {
		return 0, fmt.Errorf("inspecting remote target %s: %w", path, err)
	}
	if len(entries) == 0 {
		return resetDataFileAbsent, nil
	}
	if isBareGitRepoDir(path) {
		return resetDataGitBacked, nil
	}
	if _, err := os.Stat(filepath.Join(path, "manifest")); err == nil {
		return resetDataFileStore, nil
	}
	return 0, fmt.Errorf("remote target %s is non-empty but is neither a bare git repository nor a Dolt file store (no manifest); refusing to clear it", path)
}

// resetDataFilePath extracts the local filesystem path from a file:// URL or
// a bare absolute path, reporting whether url is file-backed at all.
func resetDataFilePath(url string) (string, bool) {
	if strings.HasPrefix(url, "file://") {
		return strings.TrimPrefix(url, "file://"), true
	}
	if filepath.IsAbs(url) {
		return url, true
	}
	return "", false
}

// isBareGitRepoDir reports whether dir looks like a bare git repository
// (HEAD file plus an objects directory).
func isBareGitRepoDir(dir string) bool {
	if fi, err := os.Stat(filepath.Join(dir, "HEAD")); err != nil || fi.IsDir() {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Verify the remote URL/path is correct (bd dolt remote -v) and points at the intended Dolt file store
  2. If the directory is a legitimate but damaged Dolt store, back it up, then delete it and re-push to rebuild from scratch
  3. If the target should be a bare git-backed remote, re-initialize it as a bare repo (git init --bare) so classification succeeds
  4. Never force-delete an unrecognized directory; inspect its contents first

Example fix

// before
bd dolt remote reset-data origin  # path=/srv/wrong-dir (no manifest)
// after
bd dolt remote set-url origin file:///srv/dolt/repo
bd dolt remote reset-data origin
Defensive patterns

Strategy: validation

Validate before calling

entries, _ := os.ReadDir(path)
_, hasManifest := os.Stat(filepath.Join(path, "manifest"))
if len(entries) > 0 && hasManifest != nil && !isBareGitRepoDir(path) {
    return fmt.Errorf("%s is neither a bare git repo nor a Dolt file store; inspect before reset", path)
}

Type guard

func isPlausibleDoltStore(path string) bool {
    _, err := os.Stat(filepath.Join(path, "manifest"))
    return err == nil
}

Try / catch

if err := runResetData(...); err != nil && strings.Contains(err.Error(), "refusing to clear") {
    // stop; inspect directory contents; do NOT force delete
}

Prevention

When it happens

Trigger: bd dolt remote reset-data targeting a file:// URL or absolute path that points at a non-empty directory containing neither .git-style bare repo layout nor a 'manifest' file — e.g. a wrong path, a partially deleted store, or an ordinary documents folder.

Common situations: Typo in the remote URL so it points at the wrong directory; a Dolt file store corrupted/truncated so the manifest is missing; pointing at a scratch directory that holds unrelated data.

Related errors


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