Skip to content

Remote Already Exists

Error message

                error: remote origin already exists.
              

Quick summary

A remote with the name you specified (e.g. origin) is already configured — you cannot add it again.

Why this happens

  • You ran git remote add origin <url> but origin already exists

  • A remote was auto-configured by git clone and you tried to re-add it

  • You are re-running a setup script that adds the remote

Minimal example

✗ Broken code
git remote add origin https://github.com/user/repo.git  # error: remote origin already exists
✓ Fixed code
# Update the existing remote URL
git remote set-url origin https://github.com/user/repo.git

# Or remove and re-add
git remote remove origin
git remote add origin https://github.com/user/repo.git

Use git remote set-url to change an existing remote's URL, or remove it first before re-adding.

How to diagnose

  • Run git remote -v to see existing remotes and their URLs

  • Check if the existing remote URL is correct

  • Verify you are not re-running a setup command

How to fix

  • If the URL is wrong, update it: git remote set-url origin <new-url>

  • If you want a different remote, use a different name: git remote add upstream <url>

  • If you want to replace it: git remote remove origin && git remote add origin <url>

How to prevent

  • Check git remote -v before adding remotes

  • Use git clone which auto-configures origin

Related Resources

Related Glossary

Related Lessons

← Back to language