gitbutlerapp/gitbutler · error
Remote name '{name}' already exists
Error message
Remote name '{name}' already exists What it means
Thrown by the add_remote command (gitbutler-repo) when a git remote with the requested name is already configured in the repository. The command deliberately refuses to overwrite: it calls repo.find_remote(name) first and bails before touching the config. Raw git would let you shadow or re-add in some flows, so users migrating scripts from plain git are often surprised.
Source
Thrown at crates/gitbutler-repo/src/commands.rs:237
}
fn remotes(&self) -> anyhow::Result<Vec<GitRemote>> {
let repo = self.repo.get()?;
repo.remote_names()
.iter()
.map(|name| -> Result<_> {
let remote = repo.find_remote(name)?;
Ok(GitRemote::from_gix(name.to_string(), &remote))
})
.collect()
}
fn add_remote(&self, name: &str, url: &str) -> Result<()> {
let repo = self.open_isolated_repo()?;
// Bail if remote with given name already exists.
if repo.find_remote(name).is_ok() {
bail!("Remote name '{name}' already exists");
}
// Bail if remote with given url already exists.
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
}View on GitHub (pinned to caf1f223d3)
Solutions
- Check existing remotes first (git remote -v, or the list_remotes command) and skip the add if the name exists
- If you meant to change the URL of the existing remote, edit it instead: git remote set-url <name> <url>
- Pick a different remote name if you genuinely need a second remote for a different URL
- Remove the old remote first (git remote remove <name>) if it should really be replaced
Example fix
# before: add_remote('origin', url) -> "Remote name 'origin' already exists"
# after: update the existing remote instead of adding a duplicate
git remote set-url origin https://github.com/org/repo.git Defensive patterns
Strategy: validation
Validate before calling
let repo = gix::open(&workdir)?;
if repo.remote_names().iter().any(|n| n == name) {
// name taken: update the existing remote's url instead of calling add_remote
} Prevention
- List remotes before adding
- Treat 'add existing name' as an update-url operation in automation
- Make onboarding scripts idempotent by checking remote names first
When it happens
Trigger: Calling the GitButler add_remote command (desktop add-remote dialog, SDK, or CLI) with a name like 'origin' in a repository whose .git/config already contains a remote with that exact name, so the initial find_remote(name).is_ok() check trips.
Common situations: Re-adding origin after changing its URL (should be an edit, not an add); onboarding/setup scripts run twice; automation assuming a clean clone; users intending to update the URL of an existing remote rather than create one.
Related errors
- Neither found push remote found in workspace nor unambiguous
- Remote with url '{url}' already exists at '{remote_name}'
- No push remote set or more than one remote
- Failed to communicate with LM Studio server: ${error instanc
- Invalid response: ${JSON.stringify(result)}
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/0821ef923c4092a1.
Report an issue: GitHub.