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.
Quick answer
error: remote origin already exists.
A remote named origin is already configured in this repository.
git remote set-url origin <new-url>Show alternative fixes
git remote add upstream <url>git remote remove origin && git remote add origin <url>git remote -verror: 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.