plandex-ai/plandex · error
error cleaning untracked files | err: %v, output: %s
Error message
error cleaning untracked files | err: %v, output: %s
What it means
GitClearUncommittedChanges runs `git reset --hard` then `git clean -d -f` to force the working tree back to HEAD. This error means the `git clean` step itself failed to execute; the combined stderr/stdout of the command is embedded in the message. It is not about files being dirty — it is the cleanup command erroring (or git being unavailable/misconfigured).
Source
Thrown at app/cli/lib/git.go:185
}
return nil
}
func GitClearUncommittedChanges() error {
gitMutex.Lock()
defer gitMutex.Unlock()
// Reset staged changes
res, err := exec.Command("git", "reset", "--hard").CombinedOutput()
if err != nil {
return fmt.Errorf("error resetting staged changes | err: %v, output: %s", err, string(res))
}
// Clean untracked files
res, err = exec.Command("git", "clean", "-d", "-f").CombinedOutput()
if err != nil {
return fmt.Errorf("error cleaning untracked files | err: %v, output: %s", err, string(res))
}
return nil
}
func GitFileHasUncommittedChanges(path string) (bool, error) {
gitMutex.Lock()
defer gitMutex.Unlock()
res, err := exec.Command("git", "status", "--porcelain", path).CombinedOutput()
if err != nil {
return false, fmt.Errorf("error checking for uncommitted changes for file %s | err: %v, output: %s", path, err, string(res))
}
return strings.TrimSpace(string(res)) != "", nil
}
func GitCheckoutFile(path string) error {View on GitHub (pinned to e2d772072e)
Solutions
- Verify the cwd is a git repository: run `git rev-parse --is-inside-work-tree` and initialize with `git init` if not.
- Confirm `git` is installed and on PATH (`which git`; install git if missing).
- Read the embedded `output:` portion of the message to see git's own stderr (e.g. permission denied) and fix that underlying issue.
- Manually run `git clean -d -f` in the repo to reproduce and inspect interactively.
Example fix
// before
res, err = exec.Command("git", "clean", "-d", "-f").CombinedOutput()
// after
if _, statErr := os.Stat(".git"); statErr != nil {
return fmt.Errorf("not a git repository, cannot clean: %w", statErr)
}
res, err = exec.Command("git", "clean", "-d", "-f").CombinedOutput() Defensive patterns
Strategy: validation
Validate before calling
if _, err := exec.LookPath("git"); err != nil { return fmt.Errorf("git not installed") }
if out, err := exec.Command("git", "rev-parse", "--is-inside-work-tree").Output(); err != nil || strings.TrimSpace(string(out)) != "true" {
return fmt.Errorf("not a git repository")
} Try / catch
if err := GitClearUncommittedChanges(); err != nil {
if strings.Contains(err.Error(), "error cleaning untracked files") {
log.Printf("git clean failed, inspect manually: %v", err)
}
return err
} Prevention
- Only call inside a confirmed git work tree
- Ensure git is on PATH in all environments (CI images especially)
- Avoid untracked files with root-only permissions
- Read the embedded `output:` field before retrying
When it happens
Trigger: Calling GitClearUncommittedChanges() when `git clean -d -f` exits non-zero: git binary missing or not on PATH, the working directory is not inside a git repository, a permission error prevents deletion, or a nested/foreign repo rejects the clean.
Common situations: Running the CLI outside a git repo (e.g. in a temp dir or home dir), a sandboxed/containerized environment where the git binary is absent, or untracked files with restrictive permissions that clean cannot remove.
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
- error checking for uncommitted changes for file %s | err: %v
- error checking out file %s | err: %v, output: %s
- failed to commit changes: %s
- error adding files to git repository for dir: %s, err: %v
- error committing files to git repository for dir: %s, err: %
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/0f599d2ac6d7ca4c.
Report an issue: GitHub.