remote origin already exists — How to fix this Git error
You tried to add a remote named "origin", but one already exists. Here is how to update it, replace it, or work with multiple remotes.
What this error means
In Git, a remote is a named reference to another repository, usually hosted on a service like GitHub, GitLab, or Bitbucket. The name origin is the conventional default for the primary remote.
When you run git remote add origin <url>, Git tries to register a new remote with the name "origin". If a remote with that name already exists in your configuration, Git stops and shows this error.
This is not a serious problem. It simply means you need to update the existing remote's URL instead of adding a new one, or remove the old remote first. Your local files and commit history are completely unaffected.
Why it happens
Running git remote add twice
You already ran git remote add origin <url> once and are trying to run it again with a different URL. Git does not overwrite existing remotes — it throws this error instead to prevent accidental changes.
Cloned repo already has origin
When you git clone a repository, Git automatically sets up a remote named "origin" pointing to the URL you cloned from. If you then try to add origin again, it conflicts with the one set up during the clone.
Copying config from another project
If you copied a .git/config file or followed setup instructions from another project, the remote "origin" may already be defined in the configuration before you run the add command.
How to fix it
Three approaches: update the URL in place, remove and re-add, or rename the old remote.
1. Update the URL (recommended)
2. Remove and re-add
3. Rename and add new
How to prevent it
Check remotes before adding
Run git remote -v before adding a new remote. This shows you all configured remotes and their URLs. If origin is already there, use set-url to update it instead of add.
Use git clone for new projects
When starting work on an existing remote repository, use git clone <url> instead of manually initializing and adding a remote. Clone handles the remote setup automatically and you never need to run git remote add.
Use descriptive remote names
If you work with multiple remotes (e.g., a fork and the upstream project), give each a descriptive name: origin for your fork and upstream for the original. This avoids naming conflicts entirely.
GitQuest is created by Anaïs (nouvelle fenêtre), web developer and head of education, specializing in tech training and digital accessibility.
FAQ — remote origin already exists
Master Git remotes with GitQuest
Practice pushing, pulling, and managing remotes through interactive challenges. Build real confidence with Git.
Start learning Git