plandex-ai/plandex · error
error checking for uncommitted changes: %v, output: %s
Error message
error checking for uncommitted changes: %v, output: %s
What it means
CheckUncommittedChanges runs `git status --porcelain` (from the process working directory) and errors if that command fails. The error embeds git's exit error and combined output. Note it runs without `-C`, so it depends on the current working directory being a repository.
Source
Thrown at app/cli/lib/git.go:100
args = append(args, paths...)
}
res, err := exec.Command("git", args...).CombinedOutput()
if err != nil {
return fmt.Errorf("error committing files to git repository for dir: %s, err: %v, output: %s", repoDir, err, string(res))
}
return nil
}
func CheckUncommittedChanges() (bool, error) {
gitMutex.Lock()
defer gitMutex.Unlock()
// Check if there are any changes
res, err := exec.Command("git", "status", "--porcelain").CombinedOutput()
if err != nil {
return false, fmt.Errorf("error checking for uncommitted changes: %v, output: %s", err, string(res))
}
// If there's output, there are uncommitted changes
return strings.TrimSpace(string(res)) != "", nil
}
func GitStashCreate(message string) error {
gitMutex.Lock()
defer gitMutex.Unlock()
res, err := exec.Command("git", "stash", "push", "--include-untracked", "-m", message).CombinedOutput()
if err != nil {
return fmt.Errorf("error creating git stash: %v, output: %s", err, string(res))
}
return nil
}
View on GitHub (pinned to e2d772072e)
Solutions
- Read the output in the message — 'not a git repository' means chdir into the repo (or os.Chdir) before calling.
- Verify git is installed: `git --version`; install git in the container/host.
- Run the process from the repository root or a subdirectory of it.
- Check GIT_DIR/GIT_WORK_TREE env overrides aren't pointing to wrong locations.
- If .git is corrupted, re-clone or restore the repository.
Example fix
// before: called from arbitrary cwd hasChanges, err := lib.CheckUncommittedChanges() // after: ensure repo root first os.Chdir(projectRoot) hasChanges, err := lib.CheckUncommittedChanges()
Defensive patterns
Strategy: try-catch
Validate before calling
// Go: ensure cwd is inside a repo before calling
out, err := exec.Command("git", "rev-parse", "--is-inside-work-tree").Output()
if err != nil || strings.TrimSpace(string(out)) != "true" {
os.Chdir(projectRoot)
} Type guard
func isStatusCheckError(err error) bool {
return err != nil && strings.Contains(err.Error(), "error checking for uncommitted changes")
} Try / catch
hasChanges, err := lib.CheckUncommittedChanges()
if err != nil {
if isStatusCheckError(err) && strings.Contains(err.Error(), "not a git repository") {
os.Chdir(repoRoot)
hasChanges, err = lib.CheckUncommittedChanges()
}
} Prevention
- Start the process with the repo root as working directory, or os.Chdir explicitly.
- Verify git exists on PATH in your deployment image.
- Avoid relying on GIT_DIR/GIT_WORK_TREE overrides unless intentional.
- Remember this function ignores the dir argument style used elsewhere — it always uses cwd.
When it happens
Trigger: Calling CheckUncommittedChanges() while the process working directory is not inside a git repository, git is not installed/on PATH, the .git directory is corrupted, or GIT_DIR/GIT_WORK_TREE env vars point somewhere invalid.
Common situations: Running the CLI from outside the project directory; running in a container image that lacks git; a detached or broken .git after a failed clone; git version too old to support a referenced option.
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 commit changes: %s
- error adding files to git repository for dir: %s, err: %v, o
- error committing files to git repository for dir: %s, err: %
- error creating git stash: %v, output: %s
- error resetting staged changes | err: %v, output: %s
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/3d5be919090b52b8.
Report an issue: GitHub.