Skip to content
fatal: remote origin already exists

fatal: remote origin already exists

DodaTech 2 min read

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 origin to the clone URL) and then tried to git remote add origin again.
  • You previously ran git remote add origin <some-url> and forgot about it.
  • You’re following a setup guide that tells you to add origin without 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 -v

You’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.git

This 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.git

4. 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.git

This is common in fork workflows where origin is your fork and upstream is the original repo.

What is 'origin' in Git?
origin is the default alias Git assigns to the URL you cloned from. It’s a convention, not a requirement — you can name remotes anything (e.g., upstream, myfork, production). origin is just the most common name for the primary remote repository.
When should I use set-url instead of rm/add?
Use git remote set-url origin <url> when you only need to change the URL — it’s a single command and preserves any remote-tracking branches and refspecs. Use git remote rm origin followed by git remote add origin <url> when you want to clear any misconfigured settings associated with the remote.
How do I rename a remote instead of replacing it?
Use git remote rename <old-name> <new-name>. For example, git remote rename origin upstream renames the existing origin to upstream, freeing the name origin for a different URL without losing any configuration.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro