GitHub "fatal: remote origin already exists"

Solution 1:

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

Solution 2:

In Short,

git remote rm origin
git remote add origin [email protected]:username/myapp.git

Worked !

Cheers!

Solution 3:

First do a:

git remote rm origin

then

git remote add origin https://github.com/your_user/your_app.git

and voila! Worked for me!

Solution 4:

You can see what remote repositories you are configured to connect to via

git remote -v

That will return a list in this format:

origin  [email protected]:github/git-reference.git (fetch)
origin  [email protected]:github/git-reference.git (push)

That might help you figure out what the original 'origin' pointed to.

If you want to keep the remote connection that you see with the -v, but still want to follow the Rails tutorial without having to remember 'github' (or some other name) for your tutorial's repo, you can rename your other repository with the command:

git remote rename [current name] [new name]

as in:

git remote rename origin oldrepo

You should then be able to resume your tutorial.