{"record":{"id":"76b4802c75a82d5d","repo":"nikivdev/code","slug":"no-git-remotes-configured-cannot-push-pr-head","errorCode":null,"errorMessage":"No git remotes configured; cannot push PR head {}","messagePattern":"No git remotes configured; cannot push PR head (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commit.rs","lineNumber":8679,"sourceCode":"        }\n        let jj_error = jj_result.unwrap_err().to_string();\n        let concise = jj_error\n            .lines()\n            .map(str::trim)\n            .find(|line| !line.is_empty())\n            .unwrap_or(\"jj failed\");\n        eprintln!(\n            \"⚠️  jj bookmark push failed ({}). Falling back to git branch push for PR head.\",\n            concise\n        );\n    }\n\n    // Fallback: push commit directly to a branch ref.\n    // Try likely writable remotes first to support fork/upstream setups.\n    let head_refspec = format!(\"{}:refs/heads/{}\", commit_sha, head);\n    let remotes = pr_push_remote_candidates(repo_root);\n    if remotes.is_empty() {\n        bail!(\"No git remotes configured; cannot push PR head {}\", head);\n    }\n\n    let mut failures: Vec<String> = Vec::new();\n    for remote in remotes {\n        let push_output = Command::new(\"git\")\n            .current_dir(repo_root)\n            .args([\"push\", \"-u\", &remote, &head_refspec])\n            .output()\n            .with_context(|| format!(\"failed to run git push for remote {remote}\"))?;\n        if push_output.status.success() {\n            return Ok(pr_head_selector_for_remote(repo_root, &remote, head));\n        }\n\n        let push_stderr = String::from_utf8_lossy(&push_output.stderr)\n            .trim()\n            .to_string();\n        let push_stdout = String::from_utf8_lossy(&push_output.stdout)\n            .trim()","sourceCodeStart":8661,"sourceCodeEnd":8697,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commit.rs#L8661-L8697","documentation":"When the git-based fallback path pushes the PR head commit directly to a branch ref (`<sha>:refs/heads/<head>`), it needs at least one configured git remote. `pr_push_remote_candidates()` returns candidates (favoring writable remotes in fork/upstream setups), and if that list is empty the tool bails immediately, since there is nowhere to push.","triggerScenarios":"Fallback direct-push path is taken and `pr_push_remote_candidates(repo_root)` returns an empty Vec — i.e. `git remote` lists no remotes in the repository.","commonSituations":"Fresh local clone-less repo (`git init` only) with no remote added; remotes removed during repo migration; running the tool in a bare or scratch checkout; typos in remote configuration scripts.","solutions":["Add a remote: `git remote add origin git@github.com:owner/repo.git`","Verify with `git remote -v` that at least one remote exists and is writable","Re-run the operation from the correct repository directory","If using forks, add both origin and upstream remotes"],"exampleFix":"// before\n$ git remote -v\n(empty)\nError: No git remotes configured; cannot push PR head review/pr-123\n// after\n$ git remote add origin git@github.com:owner/repo.git\n$ tool create-review","handlingStrategy":"validation","validationCode":"let remotes = String::from_utf8_lossy(\n    &Command::new(\"git\").args([\"remote\"]).output()?.stdout);\nif remotes.trim().is_empty() {\n    return Err(anyhow!(\"add a remote first: git remote add origin <url>\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `git remote -v` as part of project bootstrap to catch missing remotes early","Add both origin and upstream for fork workflows","Fail fast in scripts when `git remote` output is empty","Document required remotes in repo onboarding docs"],"tags":["git","remote","configuration","push"],"backgroundTag":"no-git-remote-configured","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}