Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub "fatal: remote origin already exists"

Tags:

git

github

I am trying to follow along Michael Hartl's Rails tutorial but I've run across an error.

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 following error:

Parkers-MacBook-Pro:.ssh ppreyer$ git remote add origin [email protected]:ppreyer/first_app.git fatal: remote origin already exists. 

Just wondered if anybody else has run across this problem?

like image 210
ppreyer Avatar asked Jun 05 '12 20:06

ppreyer


People also ask

What does remote origin already exists mean?

"Remote origin already exists" error The error `fatal: remote origin already exists` is caused when you attempt to create a link to a remote repository called “origin” when a remote link with that name is already configured.

How do I remove remote origin?

The git remote remove command removes a remote from a local repository. You can use the shorter git remote rm command too. The syntax for this command is: git remote rm <remote-url>. 81% of participants stated they felt more confident about their tech job prospects after attending a bootcamp.

How do I remove a remote from GitHub?

We use the command git remote rm followed by the remote name to remove a remote.


1 Answers

TL;DR you should just update the existing remote:

$ git remote set-url origin [email protected]:ppreyer/first_app.git 

Long version:

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 or update the existing one if you don't need it:

To add a new remote, called for example github instead of origin (which obviously already exists in your system), do the following:

$ git remote add github [email protected]:ppreyer/first_app.git 

Remember though, everywhere in the tutorial you see "origin" you should replace it with "github". For example $ git push origin master should now be $ git push github master.

However, if you want to see what that origin which already exists is, you can do a $ git remote -v. If you think this is there by some error, you can update it like so:

$ git remote set-url origin [email protected]:ppreyer/first_app.git 
like image 159
Agis Avatar answered Sep 21 '22 21:09

Agis