gastownhall/beads · warning
auto-export: git add failed: %w
Error message
auto-export: git add failed: %w
What it means
maybeAutoExport optionally stages the exported .beads/issues.jsonl with git when config export.git-add is true, no-git-ops is not set, and the directory is a git repo. If gitAddFile fails (git itself errored), the export state is not saved and this wrapped error is returned so the caller can warn/abort.
Source
Thrown at cmd/bd/export_auto.go:227
if issueCount == 0 && memoryCount == 0 {
_ = os.Remove(fullPath)
saveExportAutoState(beadsDir, &exportAutoState{
LastDoltCommit: currentCommit,
LastDiffAnchor: anchorCommit,
LastDirtyIDs: dirtyIDs,
Timestamp: time.Now(),
Issues: 0,
Memories: 0,
})
return nil
}
warnJSONLWithoutDoltRemote("auto-export")
// Optional git add — skip when no-git-ops is set (GH#3314), when not in a
// git repo (standalone BEADS_DIR flow), or when export.git-add is false.
if config.GetBool("export.git-add") && !config.GetBool("no-git-ops") && isGitRepo() {
if err := gitAddFile(fullPath); err != nil {
return fmt.Errorf("auto-export: git add failed: %w", err)
}
}
// Save state
newState := exportAutoState{
LastDoltCommit: currentCommit,
LastDiffAnchor: anchorCommit,
LastDirtyIDs: dirtyIDs,
Timestamp: time.Now(),
Issues: issueCount,
Memories: memoryCount,
}
saveExportAutoState(beadsDir, &newState)
return nil
}
// storeStateHash returns the hash used for auto-export change detection.
// It prefers a working-set-aware hash (storage.StateHasher) over the HEADView on GitHub (pinned to 71377f2769)
Solutions
- Re-run after the competing git process exits (check for .git/index.lock and remove it only if stale)
- Ensure the working directory is a healthy git repo (`git status`) and git is installed
- Set `no-git-ops` or export.git-add=false to skip staging; the JSONL export itself still succeeded
- Check git's own stderr via the wrapped cause for safe.directory/permission hints
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-checks matching the command's own guards
if !isGitRepo() || config.GetBool("no-git-ops") || !config.GetBool("export.git-add") { skipGitAdd() }
if _, err := os.Stat(".git/index.lock"); err == nil { deferGitAdd() } Try / catch
if err := maybeAutoExport(ctx); err != nil {
if strings.Contains(err.Error(), "git add failed") {
// export already written; stage later or disable export.git-add
log.Warn("auto-export staged export failed", "err", err)
}
} Prevention
- Don't run competing git operations (IDEs, hooks) at the same moment as bd export
- Set export.git-add=false or no-git-ops in environments where git is unreliable
- Keep git installed and the repo healthy (`git status` clean-run) in CI containers
When it happens
Trigger: gitAddFile fails: git not on PATH, path not actually in a git repo despite isGitRepo race, git index.lock held by another process, or git hook/permission failures on add.
Common situations: Concurrent `bd` and IDE git operations contending for .git/index.lock; BEADS_DIR relocated outside the repo mid-run; bare-broken git install; ownership/safe.directory errors in containers.
Related errors
- git index is locked at %s; skipping auto-stage
- failed to check git index lock %s: %w
- git add timed out after %s
- %w: %s
- failed to read .gitignore: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/6c6c4bfcf4b5453a.
Report an issue: GitHub.