fatal: remote origin already exists
Git’s fatal: remote origin already exists error occurs when you run git remote add origin <url> but a remote named “origin” is already configured for your repository.
What It Means
A Git remote is a named reference to a remote repository URL. The name origin is the conventional default for the primary remote. When you try to git remote add origin <url>, Git refuses because origin is already set — you can’t have two remotes with the same name.
Why It Happens
- You already cloned the repo (which automatically sets
originto the clone URL) and then tried togit remote add originagain. - You previously ran
git remote add origin <some-url>and forgot about it. - You’re following a setup guide that tells you to add
originwithout first checking if it exists. - A teammate shared a script that adds the remote unconditionally.
How to Fix It
1. Check the current remote URL
First, see what origin is currently set to:
git remote -vYou’ll see output like:
origin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)2. Update the existing remote URL (recommended)
If you want to change the URL that origin points to, use set-url instead of removing and re-adding:
git remote set-url origin https://github.com/user/new-repo.gitThis updates the URL without deleting the remote. Verify with git remote -v.
3. Remove and re-add the remote
If you prefer to start clean:
git remote rm origin
git remote add origin https://github.com/user/new-repo.git4. Use a different remote name
If you want to keep the existing origin and add another remote:
git remote add upstream https://github.com/other-user/repo.gitThis is common in fork workflows where origin is your fork and upstream is the original repo.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro