我有我的项目在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
但我所领受的是:
致命:远程源已经存在。
当前回答
如果你想在github中创建一个具有相同项目的新存储库,并且之前的Remote不允许你这样做,在这种情况下,首先删除github上的存储库,然后你只需要删除。git文件夹C:\Users\Shiva\AndroidStudioProjects\yourprojectname\。Git删除了这个文件夹(确保你点击了隐藏文件,因为这个文件夹是隐藏的)
同时点击android studio settings ->VersionControl中的minus(Remove)按钮 点击这里删除版本控制从android,然后你将能够创建新的存储库。
其他回答
您需要检查原点,如果不存在则添加。
if ! git config remote.origin.url >/dev/null; then
git remote add origin git@github.com:john/doe.git
fi
创建文件check.sh,粘贴脚本,更新git存储库URL,然后运行。/check.sh。
步骤: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
当您忘记进行第一次提交时,也会发生这种情况。
下面的两个命令应该有助于设置。
git remote set-url origin https://github.com/USERNAME/NEW_REPO.git
git push --set-upstream origin main
您得到这个错误是因为“origin”不可用。“origin”是一个约定,不是命令的一部分。“origin”是远程存储库的本地名称。
例如,你也可以这样写:
git remote add myorigin git@github.com:myname/oldrep.git
git remote add testtest git@github.com:myname/oldrep.git
详见说明书:
http://www.kernel.org/pub/software/scm/git/docs/git-remote.html
要删除远程存储库,请输入:
git remote rm origin
同样,如果需要的话,“origin”是远程存储库的名称 移除“上游”遥控器:
git remote rm upstream