nikivdev/code · error
could not determine repo name (use --repo)
Error message
could not determine repo name (use --repo)
What it means
run_mirror_push resolves the target repo name from --repo, or by deriving it from the repo root directory and upstream/origin remote URLs. If every source yields an empty string, it bails asking for --repo. Without a name, the tool cannot construct the fork's GitHub URL.
Source
Thrown at src/push.rs:39
let current_branch = current_branch(&repo_root)?;
let upstream_url = git_capture_in(&repo_root, &["remote", "get-url", "upstream"])
.ok()
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty());
let origin_url = git_capture_in(&repo_root, &["remote", "get-url", "origin"])
.ok()
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty());
let owner = resolve_push_owner(cmd.owner.as_deref())?;
let repo_name = if let Some(repo) = cmd.repo.as_deref() {
repo.trim().to_string()
} else {
derive_repo_name(&repo_root, upstream_url.as_deref(), origin_url.as_deref())?
};
if repo_name.is_empty() {
bail!("could not determine repo name (use --repo)");
}
let target_url = choose_github_remote_url(&owner, &repo_name, &cmd)?;
if cmd.dry_run {
println!("Repo: {}", repo_root.display());
println!("Branch: {}", current_branch);
println!("Remote: {}", cmd.remote);
println!("Target: {}", target_url);
return Ok(());
}
ensure_remote_points_to_target(
&repo_root,
&cmd.remote,
&target_url,
upstream_url.as_deref(),
cmd.force,View on GitHub (pinned to a747e741ae)
Solutions
- Pass --repo <name> explicitly
- Set a parseable remote: `git remote add upstream <github-url>` (or fix origin) so the name can be derived
- Ensure origin/upstream URLs are standard GitHub forms (git@github.com:owner/name.git or https://github.com/owner/name)
Example fix
// before f push -> could not determine repo name // after f push --repo my-fork-name # or git remote add upstream https://github.com/original/original.git
Defensive patterns
Strategy: validation
Validate before calling
let url = std::process::Command::new("git")
.args(["remote","get-url","origin"]).output().ok();
let has_name = url.map(|o| o.status.success() && !o.stdout.is_empty()).unwrap_or(false);
if !has_name {
eprintln!("pass --repo <name> or add a GitHub origin/upstream remote");
std::process::exit(1);
} Try / catch
match run_push(cmd) {
Err(e) if e.to_string().contains("could not determine repo name") => {
eprintln!("add --repo <name> or set a parseable GitHub remote");
}
other => other?,
} Prevention
- Always pass --repo in scripted/CI runs
- Keep origin or upstream pointing at standard GitHub URL forms
- Don't strip remotes from CI checkouts (clone, don't download archives)
When it happens
Trigger: No --repo flag, and derive_repo_name returns empty: the directory basename is unusable and neither the `upstream` nor `origin` remote URL exists or parses to a repo name (e.g. remotes unset or pointing at non-GitHub URLs).
Common situations: Forked repos cloned without remotes (downloaded zip → git init); origin pointing to a bare SSH alias the parser doesn't recognize; running in a repo whose folder name is empty/unexpected; CI checkouts where remotes were stripped.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- unable to determine GitHub repo (origin URL not GitHub, and
- No git remotes configured; cannot push PR head {}
- repo URL is required
- Could not determine GitHub owner. Configure it via: [git]
- No upstream remote. Use: f upstream setup --url <upstream-re
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/48264df7cb683fd6.
Report an issue: GitHub.