{"record":{"id":"16aae90fd754066e","repo":"EveryInc/compound-engineering-plugin","slug":"failed-to-reset-to-origin-branch-reseterr-tr","errorCode":null,"errorMessage":"Failed to reset to origin/${branch}. ${resetErr.trim()}","messagePattern":"Failed to reset to origin/(.+?)\\. (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/commands/plugin-path.ts","lineNumber":114,"sourceCode":"    cwd: repoDir,\n    stdout: \"pipe\",\n    stderr: \"pipe\",\n  })\n  const fetchExit = await fetch.exited\n  const fetchErr = await new Response(fetch.stderr).text()\n  if (fetchExit !== 0) {\n    throw new Error(`Failed to fetch branch '${branch}'. ${fetchErr.trim()}`)\n  }\n\n  const reset = Bun.spawn([\"git\", \"reset\", \"--hard\", `origin/${branch}`], {\n    cwd: repoDir,\n    stdout: \"pipe\",\n    stderr: \"pipe\",\n  })\n  const resetExit = await reset.exited\n  const resetErr = await new Response(reset.stderr).text()\n  if (resetExit !== 0) {\n    throw new Error(`Failed to reset to origin/${branch}. ${resetErr.trim()}`)\n  }\n}\n\nfunction resolveGitHubSource(): string {\n  const override = process.env.COMPOUND_PLUGIN_GITHUB_SOURCE\n  if (override && override.trim()) return override.trim()\n  return \"https://github.com/EveryInc/compound-engineering-plugin\"\n}\n","sourceCodeStart":96,"sourceCodeEnd":123,"githubUrl":"https://github.com/EveryInc/compound-engineering-plugin/blob/c9c10f8c75412c7232cb2bd663e5fd1cea98d84e/src/commands/plugin-path.ts#L96-L123","documentation":"After a successful fetch, `plugin-path` runs `git reset --hard origin/<branch>` to move the working tree to the remote branch tip. Non-zero exit from that reset raises this error with git's stderr. This usually means origin/<branch> reference does not exist locally even after fetching, or the repo is in an inconsistent state.","triggerScenarios":"Fetch succeeded but `origin/<branch>` ref is absent (unusual fetch behavior / partial clone), the repo directory was manually modified or corrupted (e.g. interrupted previous run), or git refuses reset because of an index.lock left behind by a concurrent process.","commonSituations":"Two plugin-path runs racing on the same target directory (index.lock); a previous run was killed mid-clone leaving a broken repo; branch renamed with the old cached ref still expected.","solutions":["Delete the target/cached repo directory and re-run for a clean clone.","Remove a stale lock: check for `<repo>/.git/index.lock` and delete it if no git process is running.","Inspect git's stderr in the message for the precise cause and address it in the cached repo.","Avoid running two plugin-path invocations for the same branch/target concurrently."],"exampleFix":"// before\nplugin-path compound-engineering --branch feat/x   # fails: index.lock\n// after\nrm -f <target-dir>/.git/index.lock && plugin-path compound-engineering --branch feat/x","handlingStrategy":"fallback","validationCode":"// If a cached repo exists, make sure it is healthy before plugin-path uses it\nif (existsSync(targetDir)) {\n  const r = Bun.spawnSync([\"git\", \"-C\", targetDir, \"status\"])\n  if (r.exitCode !== 0) { fs.rmSync(targetDir, { recursive: true, force: true }) }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const p = await pluginPath(plugin, { branch })\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"Failed to reset to origin/\")) {\n    fs.rmSync(targetDir, { recursive: true, force: true }) // nuke broken cache\n    return pluginPath(plugin, { branch })\n  } else throw e\n}","preventionTips":["Treat the cached clone as disposable: delete it on any git-state error.","Remove stale .git/index.lock files if a previous run was killed.","Serialize plugin-path runs for the same branch/target."],"tags":["git","reset","stale-cache"],"backgroundTag":"git-reset-failed","analyzedSha":"c9c10f8c75412c7232cb2bd663e5fd1cea98d84e","analyzedAt":"2026-08-31T15:18:07.959Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}