我有我的项目在GitHub上的一些位置,git@github.com:myname/oldrep.git。
现在,我想将所有代码推到其他位置的新存储库git@github.com:newname/newrep.git。
我使用命令:
git remote add origin git@github.com:myname/oldrep.git
但我所领受的是:
致命:远程源已经存在。
我有我的项目在GitHub上的一些位置,git@github.com:myname/oldrep.git。
现在,我想将所有代码推到其他位置的新存储库git@github.com:newname/newrep.git。
我使用命令:
git remote add origin git@github.com:myname/oldrep.git
但我所领受的是:
致命:远程源已经存在。
当前回答
我自己也遇到过这个问题我只是通过移除原点来移除它。 该命令将删除原点
git remote rm origin
如果您已经将远程回购添加为源,请尝试执行此命令。
其他回答
我第一次使用Bitbucket时也遇到了同样的问题。
我的问题是我需要把origin这个词改成一些自定义的东西。我使用了应用程序的名称。所以:
git remote add AppName https://someone@bitbucket.org/somewhere/something.git
步骤:1
git remote rm origin
一步:2
git remote add origin enter_your_repository_url
例子:
git remote add origin https://github.com/my_username/repository_name.git
我也有同样的问题,但我找到了解决方案。基本上,“origin”是项目克隆位置的另一个名称。现在是错误
fatal: remote origin already exists.
字面意思是原点已经存在。因此,要解决这个问题,我们的目标应该是消除它。 为此目的:
git remote rm origin
现在再添加一次
git remote add origin https://github.com/__enter your username here__/__your repositoryname.git__
这确实解决了我的问题。
下面的两个命令应该有助于设置。
git remote set-url origin https://github.com/USERNAME/NEW_REPO.git
git push --set-upstream origin main
您不必删除现有的“origin”远程,只需为远程添加使用“origin”以外的名称,例如。
Git远程添加github git@github.com:myname/oldrep.git