remote origin already exists

Inspect the existing origin, correct its URL safely, or choose a different remote name without losing commits or changing unrelated remotes.

Updated Command scenarios locally verified

Quick answer

error: remote origin already exists.

Most likely fix
What it means

A remote named origin is already configured in this repository.

Run this command
git remote set-url origin <new-url>
Show alternative fixes
git remote add upstream <url>git remote remove origin && git remote add origin <url>
Verify the resultgit remote -v

error: remote origin already exists. means the repository already has a remote named origin. Git remote names must be unique, so adding another one with that name fails. The existing remote may already be correct.

Inspect before changing anything

git remote -v
git remote get-url origin

The first command shows fetch and push URLs for every remote. Credentials should not be embedded in these URLs. If the existing origin points to the intended repository, there is nothing to add.

Change an incorrect origin URL

Use set-url rather than removing and recreating the remote:

git remote set-url origin https://example.com/owner/repository.git
git remote -v

This changes configuration only; it does not rewrite commits or modify working files. Replace the example with the exact verified URL.

Keep both remotes

If the existing origin is useful and the new URL represents a different repository, choose a descriptive name:

git remote add upstream https://example.com/original/repository.git
git remote -v

A common fork workflow uses origin for your fork and upstream for the source repository. Names are conventions, not special Git keywords.

Remove a remote only when it is obsolete

git remote remove origin

This removes the remote-tracking configuration. It does not delete the remote repository, local branches, or local commits, but it may remove remote-tracking references such as origin/main. Prefer set-url when you only need to correct an address.

If you are switching protocols, compare HTTPS vs. SSH for Git before changing the URL.

Sources and review

Last reviewed September 4, 2026. Technical claims are based on primary documentation and local command verification.