nikivdev/code · error
No upstream remote. Use: f upstream setup --url <upstream-re
Error message
No upstream remote. Use: f upstream setup --url <upstream-repo-url>
What it means
`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>`.
Source
Thrown at src/upstream.rs:166
depth: Option<u32>,
) -> Result<()> {
// Check if upstream remote exists
let has_upstream = git_capture(&["remote", "get-url", "upstream"]).is_ok();
if !has_upstream {
if let Some(url) = upstream_url {
println!("Adding upstream remote: {}", url);
git_run(&["remote", "add", "upstream", url])?;
} else {
// Try to detect from origin
if let Ok(origin_url) = git_capture(&["remote", "get-url", "origin"]) {
println!("No upstream remote configured.");
println!("Current origin: {}", origin_url.trim());
println!("\nTo add upstream, run:");
println!(" f upstream setup --url <original-repo-url>");
return Ok(());
}
bail!("No upstream remote. Use: f upstream setup --url <upstream-repo-url>");
}
} else {
let url = git_capture(&["remote", "get-url", "upstream"])?;
println!("✓ upstream remote exists: {}", url.trim());
}
// Fetch upstream
println!("\nFetching upstream...");
if let Some(depth) = depth {
let depth_str = depth.to_string();
git_run(&["fetch", "upstream", "--prune", "--depth", &depth_str])?;
} else {
git_run(&["fetch", "upstream", "--prune"])?;
}
// Determine upstream branch (explicit > HEAD > main > master)
let upstream_branch = if let Some(branch) = upstream_branch {
branch.to_string()View on GitHub (pinned to a747e741ae)
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.
Example fix
// before (fails) f upstream sync // after f upstream setup --url https://github.com/original-owner/original-repo.git f upstream sync
Defensive patterns
Strategy: validation
Validate before calling
# guard before running upstream commands
git remote get-url upstream >/dev/null 2>&1 || { echo "run: f upstream setup --url <upstream-repo-url>"; exit 1; } Prevention
- 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.
When it happens
Trigger: 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`.
Common situations: 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.
Related errors
- No git remotes configured; cannot push PR head {}
- Specify branch with: f upstream setup --branch <branch-name>
- missing push remote for {}
- unable to determine GitHub repo (origin URL not GitHub, and
- failed to push PR head {} to any remote: {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/1a92b80ba233c901.
Report an issue: GitHub.