plandex-ai/plandex · error

error getting untracked files in git repo: %s

Error message

error getting untracked files in git repo: %s

What it means

The untracked-files goroutine runs `git ls-files --others --exclude-standard` in baseDir to list untracked but non-ignored files. This error is thrown when that git command exits non-zero, aborting GetPaths. Like the other git wrappers, the underlying exec error is embedded in the message via %s.

Source

Thrown at app/cli/fs/paths.go:138

				parentDir := relFile
				for parentDir != "." && parentDir != "/" && parentDir != "" {
					parentDir = filepath.Dir(parentDir)
					activeDirs[parentDir] = true
				}
			}

			errCh <- nil
		}()

		// get all untracked non-ignored files in the repo
		numRoutines++
		go func() {
			cmd := exec.Command("git", "ls-files", "--others", "--exclude-standard")
			cmd.Dir = baseDir
			out, err := cmd.Output()

			if err != nil {
				errCh <- fmt.Errorf("error getting untracked files in git repo: %s", err)
				return
			}

			files := strings.Split(string(out), "\n")

			mu.Lock()
			defer mu.Unlock()
			for _, file := range files {
				absFile := filepath.Join(baseDir, file)
				relFile, err := filepath.Rel(currentDir, absFile)

				if err != nil {
					errCh <- fmt.Errorf("error getting relative path: %s", err)
					return
				}

				if ignored != nil && ignored.MatchesPath(relFile) {
					continue

View on GitHub (pinned to e2d772072e)

Solutions

  1. Run `git ls-files --others --exclude-standard` manually in the project directory and fix the reported git error.
  2. Add the repo to safe.directory when ownership mismatch is reported: `git config --global --add safe.directory <path>`.
  3. Ensure git is installed and functional (`git --version`) in the environment.
  4. Repair or re-clone the repository if the index or .git metadata is corrupt.
Defensive patterns

Strategy: validation

Validate before calling

if out, err := exec.Command("git", "-C", baseDir, "ls-files", "--others", "--exclude-standard").Output(); err != nil {
	return fmt.Errorf("untracked-file listing failed in %s: %s", baseDir, err)
}

Try / catch

if err := <-errCh; err != nil {
	if strings.Contains(err.Error(), "error getting untracked files in git repo") {
		// inspect the wrapped git error and repair repo or environment
	}
}

Prevention

When it happens

Trigger: Calling GetPaths where `git ls-files --others --exclude-standard` fails: corrupt index (this command reads the index to exclude tracked files), dubious-ownership safe.directory rejection, git binary missing, permissions problems on .git, or a huge/deep repo hitting resource limits.

Common situations: Running as a different user than the repo owner (containers, sudo); interrupted git operations leaving .git in a bad state; minimal CI images without git; read-only mounts preventing git from reading required files.

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


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/340eb44c5079cbce. Report an issue: GitHub.