简体   繁体   中英

Git error message “remote origin already exists”

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!

The 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 <folder_name> . 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

Open up .git/config and manually change the url of the remote repository under [remote "origin"] . Then try it again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM