如何切换我的 git 存储库的 url



我有一个本地目录,该目录之前已配置了git存储库,并托管在名为BitBucket的服务上。

现在我在 GitHub 中创建了一个存储库,并希望更新对该存储库的本地引用,但我收到此错误:

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'

新存储库位于以下 URL 中:

git remote add origin https://github.com/genadinik/iPhoneBusinessPlan.git

知道如何将本地引用切换到 github 网址吗?

还有一个(子)命令来更改URL:

git remote set-url origin https://github.com/genadinik/iPhoneBusinessPlan.git

这样就无需重新获取数据。

当然,只需先删除原点:

$ git remote rm origin
$ git remote add origin https://github.com/genadinik/iPhoneBusinessPlan.git

编辑 如果您在切换远程后从现有源从头开始创建存储库,那么您可以执行以下操作:

$ git add -A
$ git commit -m "init"
$ git push origin master

相关内容

最新更新