Github “fatal: remote origin already exists”

1.0K    Asked by Asisthapandey in Python , Asked on Jul 4, 2021

 I signed up on Github and issued a new SSH key and made a new repository. But when I enter the next line into the terminal I get the error ”remote origin already exists” as shown below:

Parkers-MacBook-Pro:.ssh ppreyer$ git remote add origin git@github.com:ppreyer/first_app.git
fatal: remote origin already exists.

How can I resolve this error?


Answered by Clare Matthews

For this type of error you should just update the existing remote using:

        $ git remote set-url origin git@github.com:ppreyer/first_app.git

As the error message indicates, there is already a remote configured with the same name. So you can either add the new remote with a different name:

To add a new remote, for example, github instead of origin, do the following:

        $ git remote add github git@github.com:ppreyer/first_app.git

While pushing you should use

        git push github master

Thus, you can resolve the error “remote origin already exists” by creating a new remote with a different name instead of origin.



Your Answer

Interviews

Parent Categories