FIX · ERROR

"Remote origin
already exists."

You ran git remote add origin and Git refused. Your repo already has a remote named origin. You do not need to add it again. You need to look at it, then change it or leave it.

git remote -vset-urlremote renameremote remove

The short answer

look first
1

Look

git remote -v lists every remote and its URL. If origin already points where you want, you are done.

2

Point it elsewhere

git remote set-url origin NEW-URL changes where origin points. This is the usual fix.

3

Start over

git remote remove origin, then run your git remote add origin URL again. The git remote rm spelling does the same.

Removing a remote only deletes the link in your local repository. It does not delete anything on GitHub.

What it looks like

message from GitHub Docs

This is the message as shown in the GitHub Docs page on managing remotes. A remote name can only exist once per repository, so Git will not overwrite it for you.

Pick the fix that fits

what you want
you want to
run
result
Use a different repo URL
git remote set-url origin https://github.com/OWNER/REPOSITORY.git
Same remote name, new address. Works for HTTPS and SSH URLs.
Keep both remotes
git remote add upstream URL
Use a different name. upstream is the usual choice for the original repo of a fork.
Free up the name origin
git remote rename origin old-origin
The old remote keeps working under its new name. Then add the new origin.
Remove it and start clean
git remote remove origin
Only the local link goes away. You can add origin again straight after.

Check before and after

always

Run git remote -v before you change anything, and again after. Each remote shows once for fetch and once for push. After set-url both lines show the new address. Then git push -u origin main pushes to the new place, using whichever branch name you have.

When it goes wrong

related messages
fatal: not a git repository (or any of the parent directories): .gitYou are not inside a repositorySee the fix for this error.

Questions people ask

Why does git say remote origin already exists?

Your repository already has a remote named origin, often from git clone, which sets it up for you. Names are unique, so git remote add origin fails.

How do I change the origin URL in Git?

Run git remote set-url origin NEW-URL, then check it with git remote -v.

Does git remote remove origin delete my GitHub repository?

No. It only removes the link from your local repository. The repository on GitHub is untouched.

How do I keep two remotes?

Give the second one a different name, for example git remote add upstream URL. Each remote name can exist once.

Git, Visually · Parts 1 and 2 · English