{"record":{"id":"1a92b80ba233c901","repo":"nikivdev/code","slug":"no-upstream-remote-use-f-upstream-setup-url-u","errorCode":null,"errorMessage":"No upstream remote. Use: f upstream setup --url <upstream-repo-url>","messagePattern":"No upstream remote\\. Use: f upstream setup --url <upstream-repo-url>","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/upstream.rs","lineNumber":166,"sourceCode":"    depth: Option<u32>,\n) -> Result<()> {\n    // Check if upstream remote exists\n    let has_upstream = git_capture(&[\"remote\", \"get-url\", \"upstream\"]).is_ok();\n\n    if !has_upstream {\n        if let Some(url) = upstream_url {\n            println!(\"Adding upstream remote: {}\", url);\n            git_run(&[\"remote\", \"add\", \"upstream\", url])?;\n        } else {\n            // Try to detect from origin\n            if let Ok(origin_url) = git_capture(&[\"remote\", \"get-url\", \"origin\"]) {\n                println!(\"No upstream remote configured.\");\n                println!(\"Current origin: {}\", origin_url.trim());\n                println!(\"\\nTo add upstream, run:\");\n                println!(\"  f upstream setup --url <original-repo-url>\");\n                return Ok(());\n            }\n            bail!(\"No upstream remote. Use: f upstream setup --url <upstream-repo-url>\");\n        }\n    } else {\n        let url = git_capture(&[\"remote\", \"get-url\", \"upstream\"])?;\n        println!(\"✓ upstream remote exists: {}\", url.trim());\n    }\n\n    // Fetch upstream\n    println!(\"\\nFetching upstream...\");\n    if let Some(depth) = depth {\n        let depth_str = depth.to_string();\n        git_run(&[\"fetch\", \"upstream\", \"--prune\", \"--depth\", &depth_str])?;\n    } else {\n        git_run(&[\"fetch\", \"upstream\", \"--prune\"])?;\n    }\n\n    // Determine upstream branch (explicit > HEAD > main > master)\n    let upstream_branch = if let Some(branch) = upstream_branch {\n        branch.to_string()","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/upstream.rs#L148-L184","documentation":"`setup_upstream_internal` (src/upstream.rs:~160) looks for a git remote named `upstream` to sync with the original repository. When no such remote exists, it bails with a message telling the user how to configure one via `f upstream setup --url <upstream-repo-url>`.","triggerScenarios":"Running an upstream sync/setup command in a repo where `git remote get-url upstream` fails (no remote named `upstream`); typically a fresh clone that only has `origin`.","commonSituations":"Cloning your own fork of a project (origin = fork) and forgetting to add the original repo as `upstream`; a colleague's repo cloned without upstream config; remote was removed or renamed.","solutions":["Add the remote: `f upstream setup --url <original-repo-url>` (or `git remote add upstream <url>`).","List existing remotes with `git remote -v` to confirm `upstream` is missing or renamed.","If the original repo URL changed (renamed/moved), use its new URL in the setup command.","Run `f upstream setup` with no URL first to see the guided output including origin info."],"exampleFix":"// before (fails)\nf upstream sync\n// after\nf upstream setup --url https://github.com/original-owner/original-repo.git\nf upstream sync","handlingStrategy":"validation","validationCode":"# guard before running upstream commands\ngit remote get-url upstream >/dev/null 2>&1 || { echo \"run: f upstream setup --url <upstream-repo-url>\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After forking and cloning, immediately add upstream: `git remote add upstream <original-url>`.","Run `git remote -v` to confirm remotes before sync workflows.","Remember upstream URL changes if the original repo is renamed/moved.","Standardize upstream setup in team onboarding docs/scripts."],"tags":["git","remote","upstream","configuration"],"backgroundTag":"missing-git-remote","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}