{"record":{"id":"b1ef622cbc00169a","repo":"plandex-ai/plandex","slug":"error-resetting-file-s-v","errorCode":null,"errorMessage":"error resetting file %s: %v","messagePattern":"error resetting file (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/git.go","lineNumber":154,"sourceCode":"\t\tlog.Println(\"Error popping git stash:\", string(res))\n\n\t\tif strings.Contains(string(res), PopStashConflictMsg) {\n\t\t\tlog.Println(\"Conflicts detected\")\n\n\t\t\tif !forceOverwrite {\n\t\t\t\treturn fmt.Errorf(\"conflict popping git stash: %s\", string(res))\n\t\t\t}\n\n\t\t\t// Parse the output to find which files have conflicts\n\t\t\tconflictFiles := parseConflictFiles(string(res))\n\n\t\t\tlog.Println(\"Conflicting files:\", conflictFiles)\n\n\t\t\tfor _, file := range conflictFiles {\n\t\t\t\t// Reset each conflicting file individually\n\t\t\t\tcheckoutRes, err := exec.Command(\"git\", \"checkout\", \"--ours\", file).CombinedOutput()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error resetting file %s: %v\", file, string(checkoutRes))\n\t\t\t\t}\n\t\t\t}\n\t\t\tdropRes, err := exec.Command(\"git\", \"stash\", \"drop\").CombinedOutput()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error dropping git stash: %v\", string(dropRes))\n\t\t\t}\n\t\t\treturn nil\n\t\t} else {\n\t\t\tlog.Println(\"No conflicts detected\")\n\n\t\t\treturn fmt.Errorf(\"error popping git stash: %v\", string(res))\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc GitClearUncommittedChanges() error {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/git.go#L136-L172","documentation":"During force-overwrite conflict resolution in GitStashPop, each conflicted file is reset via `git checkout --ours <file>`. This error wraps a failure of that per-file checkout, including the file name and git's output. It aborts the conflict-resolution loop, leaving remaining conflicts and the stash un-dropped.","triggerScenarios":"GitStashPop(true) hit conflicts and, while resetting each parsed conflict file, `git checkout --ours <file>` failed — typically because the parsed file path is wrong (parseConflictFiles output mismatch on a different git version), the file is unmerged and checkout refuses, or the path no longer exists.","commonSituations":"Different git versions emit conflict output in a format parseConflictFiles doesn't fully expect (the code itself notes it was only tested against git 2.39.3), yielding mangled file names; files deleted/renamed since the stash; unmerged index entries requiring `git checkout HEAD --` or index reset instead.","solutions":["Check the file name in the error; run `git -C <repo> checkout --ours -- <file>` manually to see the real error.","If paths look mangled, manually resolve: `git checkout HEAD -- .` or `git reset --hard` then `git stash drop`.","Clear unmerged index entries with `git reset` before retrying the checkout.","Pin/verify the git version behavior against 2.39.3, since parseConflictFiles is version-sensitive.","As a last resort abort resolution: `git reset --hard` + `git stash drop` to restore a clean state."],"exampleFix":"// before: relying on version-sensitive parse\nerr := lib.GitStashPop(true)\n// after: manual recovery on failure\nif err := lib.GitStashPop(true); err != nil {\n    exec.Command(\"git\", \"reset\", \"--hard\").Run()\n    exec.Command(\"git\", \"stash\", \"drop\").Run()\n}","handlingStrategy":"fallback","validationCode":"// Go: verify git version matches the format parseConflictFiles expects\nout, _ := exec.Command(\"git\", \"version\").Output()\nif !strings.Contains(string(out), \"2.39\") {\n    // prefer manual resolution path instead of forceOverwrite parsing\n}","typeGuard":"func isResetFileError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"error resetting file \")\n}","tryCatchPattern":"if err := lib.GitStashPop(true); err != nil {\n    if isResetFileError(err) {\n        // recover: hard reset and drop stash to return to a clean state\n        exec.Command(\"git\", \"reset\", \"--hard\").Run()\n        exec.Command(\"git\", \"stash\", \"drop\").Run()\n    }\n}","preventionTips":["Pin the git version in your environment (parseConflictFiles was validated only on 2.39.3).","Test force-overwrite pop against your git version before relying on it in production.","Have a recovery path (reset --hard + stash drop) ready when force resolution fails midway.","Prefer committing or discarding local changes over triggering stash conflicts at all."],"tags":["git","stash","conflict","checkout","go"],"backgroundTag":"git-conflict-resolution-failed","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"}