I have a local directory which has been previously configure with a git repository and hosted on a service called BitBucket.
Now I made a repository in GitHub and want to update the local reference to that, but I got this error:
git remote add origin https://github.com/genadinik/iPhoneBusinessPlan.git
fatal: remote origin already exists.
Alexs-MacBook-Pro-2:BusinessPlan alexgenadinik$ git push -u origin master
error: src refspec master does not match any.
error: failed to push some refs to 'https://genadinik@bitbucket.org/genadinik/ios_business_app.git'
And the new repository is in this url:
git remote add origin https://github.com/genadinik/iPhoneBusinessPlan.git
Any idea how I can switch the local reference to the github url?
Sure, just remove the origin first:
$ git remote rm origin
$ git remote add origin https://github.com/genadinik/iPhoneBusinessPlan.git
Edit if you are doing a repository from scratch from existing sources, after switching remotes, then you could then do:
$ git add -A
$ git commit -m "init"
$ git push origin master
There's also a (sub)command to change the URL:
git remote set-url origin https://github.com/genadinik/iPhoneBusinessPlan.git
This way there's no need to re-fetch the data.
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.