plandex-ai/plandex · error

error executing git reset for dir: %s, sha: %s, err: %v, out

Error message

error executing git reset for dir: %s, sha: %s, err: %v, output: %s

What it means

gitRewindToSha: `git reset --hard <sha>` in the plan repo returned a non-zero exit. The combined git output is embedded in the error. Typical causes: unknown/corrupt sha, bare/damaged repo, or git lock issues.

Source

Thrown at app/server/db/git.go:463

	log.Printf("[Git] gitCheckoutBranch - currentBranch: %s", currentBranch)

	if currentBranch == branch {
		log.Printf("[Git] gitCheckoutBranch - already on branch %s, skipping", branch)
		return nil
	}

	log.Println("[Git] gitCheckoutBranch - checking out branch:", branch)
	res, err := exec.Command("git", "-C", repoDir, "checkout", branch).CombinedOutput()
	if err != nil {
		return fmt.Errorf("error checking out git branch for dir: %s, err: %v, output: %s", repoDir, err, string(res))
	}
	return nil
}

func gitRewindToSha(repoDir, sha string) error {
	res, err := exec.Command("git", "-C", repoDir, "reset", "--hard", sha).CombinedOutput()
	if err != nil {
		return fmt.Errorf("error executing git reset for dir: %s, sha: %s, err: %v, output: %s", repoDir, sha, err, string(res))
	}

	return nil
}

func getLatestCommit(dir string) (sha, body string, err error) {
	var out bytes.Buffer
	cmd := exec.Command("git", "log", "--pretty=%h@@|@@%at@@|@@%B@>>>@")
	cmd.Dir = dir
	cmd.Stdout = &out
	err = cmd.Run()
	if err != nil {
		return "", "", fmt.Errorf("error getting git history for dir: %s, err: %v", dir, err)
	}

	// Process the log output to get it in the desired format.
	history := processGitHistoryOutput(strings.TrimSpace(out.String()))

View on GitHub (pinned to e2d772072e)

Solutions

  1. Read the embedded git output for the specific failure
  2. Verify the sha exists in the repo (git cat-file -t)
  3. Check for a stale index.lock and repo corruption (git fsck)
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at app/server/db/git.go:463 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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