{"record":{"id":"7bdcd3261220f9f3","repo":"plandex-ai/plandex","slug":"error-executing-git-reset-for-dir-s-sha-s-er","errorCode":null,"errorMessage":"error executing git reset for dir: %s, sha: %s, err: %v, output: %s","messagePattern":"error executing git reset for dir: (.+?), sha: (.+?), err: (.+?), output: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/git.go","lineNumber":463,"sourceCode":"\tlog.Printf(\"[Git] gitCheckoutBranch - currentBranch: %s\", currentBranch)\n\n\tif currentBranch == branch {\n\t\tlog.Printf(\"[Git] gitCheckoutBranch - already on branch %s, skipping\", branch)\n\t\treturn nil\n\t}\n\n\tlog.Println(\"[Git] gitCheckoutBranch - checking out branch:\", branch)\n\tres, err := exec.Command(\"git\", \"-C\", repoDir, \"checkout\", branch).CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error checking out git branch for dir: %s, err: %v, output: %s\", repoDir, err, string(res))\n\t}\n\treturn nil\n}\n\nfunc gitRewindToSha(repoDir, sha string) error {\n\tres, err := exec.Command(\"git\", \"-C\", repoDir, \"reset\", \"--hard\", sha).CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error executing git reset for dir: %s, sha: %s, err: %v, output: %s\", repoDir, sha, err, string(res))\n\t}\n\n\treturn nil\n}\n\nfunc getLatestCommit(dir string) (sha, body string, err error) {\n\tvar out bytes.Buffer\n\tcmd := exec.Command(\"git\", \"log\", \"--pretty=%h@@|@@%at@@|@@%B@>>>@\")\n\tcmd.Dir = dir\n\tcmd.Stdout = &out\n\terr = cmd.Run()\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"error getting git history for dir: %s, err: %v\", dir, err)\n\t}\n\n\t// Process the log output to get it in the desired format.\n\thistory := processGitHistoryOutput(strings.TrimSpace(out.String()))\n","sourceCodeStart":445,"sourceCodeEnd":481,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/git.go#L445-L481","documentation":"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.","triggerScenarios":"Thrown at app/server/db/git.go:463 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the embedded git output for the specific failure","Verify the sha exists in the repo (git cat-file -t)","Check for a stale index.lock and repo corruption (git fsck)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}