gastownhall/beads · error
failed to untrack files
Error message
failed to untrack files: %w %s
What it means
FixTrackedRuntimeFiles removes runtime files from git tracking with 'git rm --cached --' while keeping local copies. If that git command fails, the combined error and git output are wrapped with this message so the user can see git's own complaint.
Solutions
- Read the appended git output for the exact git error
- Run 'git rm --cached -- <file>' manually for the listed files to see the failure directly
- Ensure you are inside a git repository and no stale .git/index.lock exists (remove it if no git process is running)
Example fix
// before
out, err := cmd.CombinedOutput() // fatal: pathspec 'runtime.db' did not match
// after
if isTracked(repoRoot, f) { untrack(f) } // skip files git does not track Defensive patterns
Strategy: validation
Validate before calling
func isTracked(repo, f string) bool {
out, err := exec.Command("git", "-C", repo, "ls-files", "--error-unmatch", f).CombinedOutput()
return err == nil && len(out) > 0
}
// only pass tracked files to FixTrackedRuntimeFiles Try / catch
if err != nil && strings.Contains(err.Error(), "failed to untrack files") {
log.Printf("git rm --cached failed: %s", gitOutput) // appended after \\n
} Prevention
- Verify repoRoot is inside a git worktree before fixing
- Skip files git does not track (git ls-files check)
- Clear stale .git/index.lock when no git process is active
When it happens
Trigger: exec.Command("git", ["rm","--cached","--",files...]).CombinedOutput() returns an error: not a git repo, files not actually tracked, pathspec mismatches, or index.lock contention.
Common situations: Running the fix outside a git worktree (repoRoot wrong); runtime files already untracked; another git process holding index.lock; case-sensitivity pathspec mismatch on macOS/Windows.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- failed to init git in planning repo
- failed to untrack last-touched file
- failed to untrack redirect file
- RepoRoot no longer exists
- unexpected git rev-parse output
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/fbdfd162e9c85703.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/bd/doctor/tracked_runtime.go:253
if err != nil {
continue
}
if shouldFlagTrackedFile(rel) {
toUntrack = append(toUntrack, line)
}
}
if len(toUntrack) == 0 {
return nil
}
// Untrack files (keeps local copies)
args := append([]string{"rm", "--cached", "--"}, toUntrack...)
cmd = exec.Command("git", args...) // #nosec G204 - args are constructed from known parts
cmd.Dir = repoRoot
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("failed to untrack files: %w\n%s", err, string(out))
}
return nil
}
View on GitHub (pinned to 71377f2769)