nikivdev/code · error
remote '{}' already points to {} refusing to overwrite witho
Error message
remote '{}' already points to {}
refusing to overwrite without --force
(target would be {}) What it means
This error is raised by ensure_remote_points_to_target in src/push.rs when a git remote already exists with a URL that differs from the target URL the mirror-push flow wants to use, and the existing URL is not the known upstream clone URL. The tool refuses to silently repoint an existing remote because doing so could break a user's deliberate remote configuration; it demands an explicit --force.
Source
Thrown at src/push.rs:266
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty());
if let Some(existing) = existing {
if normalize_git_url(&existing) == normalize_git_url(target_url) {
return Ok(());
}
// Safe override when the remote points at upstream (read-only clone).
let is_upstream = upstream_url
.map(|u| normalize_git_url(u) == normalize_git_url(&existing))
.unwrap_or(false);
if is_upstream || force {
println!("==> Updating remote {} url...", remote);
git_run_in(repo_root, &["remote", "set-url", remote, target_url])?;
return Ok(());
}
bail!(
"remote '{}' already points to {}\nrefusing to overwrite without --force\n(target would be {})",
remote,
existing,
target_url
);
}
println!("==> Adding remote {}...", remote);
git_run_in(repo_root, &["remote", "add", remote, target_url])?;
Ok(())
}
pub(crate) fn ensure_github_repo_exists(owner: &str, repo: &str) -> Result<()> {
let full_name = format!("{}/{}", owner.trim(), repo.trim());
let view = Command::new("gh")
.args(["repo", "view", &full_name])
.stdin(Stdio::null())View on GitHub (pinned to a747e741ae)
Solutions
- Re-run the command with --force to allow overwriting the remote URL
- Verify the remote URL with `git remote get-url <remote>` and confirm which URL is correct; update it manually with `git remote set-url <remote> <url>`
- If the existing remote should stay as-is, remove it (`git remote remove <remote>`) or add the target under a different remote name
Example fix
// before: remote points elsewhere, push fails $ f push remote 'origin' already points to https://github.com/old/repo.git refusing to overwrite without --force // after $ f push --force
Defensive patterns
Strategy: validation
Validate before calling
let existing = std::process::Command::new("git").args(["remote", "get-url", remote]).output()?;
let mismatch = existing.status.success()
&& normalize(existing.stdout_str()) != normalize(target_url);
if mismatch { eprintln!("remote {remote} differs from target; pass --force to overwrite"); } Try / catch
match result {
Err(e) if e.to_string().contains("refusing to overwrite without --force") => {
// surface a prompt or auto-retry with force
}
Err(e) => return Err(e),
Ok(v) => Ok(v),
} Prevention
- Check `git remote -v` before running mirror push
- Use --force deliberately only when you know the remote should be repointed
- Keep remote URLs in sync with the upstream/fork layout
When it happens
Trigger: Running the mirror push when the named remote (e.g. 'origin' or a Flow remote) exists but points to a URL different from the computed target URL, the existing URL does not normalize-match the upstream URL, and no --force flag was passed.
Common situations: The repo was cloned from upstream and the remote was manually repointed to a fork; the remote URL was edited by hand or by another tool; the target repo was renamed/moved on GitHub so the target URL changed; mixed SSH vs HTTPS URLs that do not normalize to the same value.
Related errors
- No git remotes configured; cannot push PR head {}
- failed to push PR head {} to any remote: {}
- git push {} {} failed
- No upstream remote. Use: f upstream setup --url <upstream-re
- missing push remote for {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/272c3d8e36a77d75.
Report an issue: GitHub.