git config_error ai_generated true

fatal: remote origin already exists

ID: git/remote-already-exists

Also available as: JSON · Markdown
98%Fix Rate
95%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2 active

Root Cause

Trying to add a remote that already exists.

generic

Workarounds

  1. 98% success Update existing remote URL: git remote set-url origin <new-url>
    git remote set-url origin https://github.com/user/repo.git

    Sources: https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emset-urlem

  2. 92% success Remove and re-add: git remote remove origin && git remote add origin <url>
    git remote remove origin && git remote add origin

    Sources: https://git-scm.com/docs/git-remote

Dead Ends

Common approaches that don't work:

  1. Delete the .git folder and reinitialize 95% fail

    Destroys all commit history

  2. Create a new remote with a different name 60% fail

    Having two remotes for the same repo is confusing

Error Chain

Frequently confused with: