I created a repo on github, then tried to connect to it and got this error: $ git remote add origin https://github.com/jatalamo/heroku-test-site.git fatal: remote origin already exists. This did not happen yesterday when I created a different repo. Can anyone help me figure out how to push to this existing repo on gibash? I'm a total newbie!
asked Nov 1, 2015 at 15:01 Jill Talamo Jill Talamo 51 1 1 silver badge 6 6 bronze badgesFirst: git remote remove origin
Second: git remote add origin https://(token)@github.com/username/repository-name
It always works for me. If not, I realized that I made mistakes.
answered Aug 16, 2023 at 15:01 Agung Sudrajat Agung Sudrajat 328 1 1 silver badge 10 10 bronze badgesThe reason you're getting remote origin already exist is because a remote by the name of origin already exists. You can check by typing git remote -v which will show you all the remotes of your git repo. You should see this:
origin https://github.com/jatalamo/heroku-test-site.git (fetch) origin https://github.com/jatalamo/heroku-test-site.git (push)
The command to clone your github repo is git clone https://github.com/jatalamo/heroku-test-site.git . If you do that a remote called origin would be automatically setup for you, therefore you do not need to add https://github.com/jatalamo/heroku-test-site.git as a remote manually by typing git remote add origin https://github.com/jatalamo/heroku-test-site.git .
The case in which you would need to type git remote add origin https://github.com/jatalamo/heroku-test-site.git is when you are not cloning from github but instead you typed git init on your local machine and there is not remote, so you'll have to manually add the github url as a remote called origin or whatever other name you like.
You should be able to then pull and push using these commands:
git pull origin master git push origin master