gitbutlerapp/gitbutler · error
Remote with url ' ' already exists at
Error message
Remote with url '{url}' already exists at '{remote_name}' What it means
add_remote also refuses to add a remote whose URL is already used by another remote in the repository, reporting which remote name already points at that URL. This prevents two remotes with identical URLs.
Solutions
- Reuse the existing remote name reported in the message instead of adding a new one.
- Choose a different repository/URL if you truly need a second remote.
- Remove the existing remote (git remote remove <name>) if it should be replaced, then add the new one.
Example fix
// before
repo.add_remote("upstream", "https://github.com/org/repo.git")?; // same URL as origin
// after
repo.add_remote("upstream", "https://github.com/org/fork.git")?; Defensive patterns
Strategy: validation
Validate before calling
let url_taken = repo.remote_names().iter().any(|n| {
repo.find_remote(n).ok()
.and_then(|r| r.url().map(|u| u == url))
.unwrap_or(false)
});
if url_taken { /* reuse the existing remote */ } Try / catch
match result {
Err(e) if e.to_string().contains("already exists") => {
// resolve the reported remote_name and reuse it
}
Err(e) => return Err(e),
Ok(r) => r,
} Prevention
- Scan existing remote URLs before registering a new remote.
- Keep one canonical remote per URL.
- Make onboarding flows idempotent (lookup-then-create).
When it happens
Trigger: Calling add_remote(name, url) when some existing remote's URL equals `url` (case-insensitive scan of repo.remote_names()), e.g. adding "upstream" with the same URL as "origin".
Common situations: Adding the same repository under a new name; re-running onboarding against an already-configured repo; typo where the new remote's URL duplicates an existing one.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- Remote name ' ' already exists
- Cannot reconcile : branch name ' ' occurs more than once
- failed to determine remote for non remote-tracking branch
- Remote with url already exists.
- Remote with name already exists.
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/fa43b6cef1bea881.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gitbutler-repo/src/commands.rs:274
if let Some(remote_name) = repo
.remote_names()
.iter()
.filter_map(|name| repo.find_remote(name).ok())
.find_map(|remote| {
remote
.url(gix::remote::Direction::Fetch)
.and_then(|remote_url| {
if remote_url.to_bstring() == url {
remote
.name()
.and_then(|n| n.as_symbol().map(ToOwned::to_owned))
} else {
None
}
})
})
{
bail!("Remote with url '{url}' already exists at '{remote_name}'");
}
edit_repo_config(&repo, gix::config::Source::Local, |config| {
let mut section = config.section_mut_or_create_new("remote", Some(name.into()))?;
section.push("url", Some(url.as_bytes().as_bstr()))?;
ensure_config_value(
config,
&format!("remote.{name}.fetch"),
&format!("+refs/heads/*:refs/remotes/{name}/*"),
)?;
Ok(())
})?;
Ok(())
}
fn read_file_from_commit(
&self,
commit_id: gix::ObjectId,View on GitHub (pinned to 58e5313667)