我有我的项目在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
但我所领受的是:
致命:远程源已经存在。
当前回答
步骤: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”远程,只需为远程添加使用“origin”以外的名称,例如。
Git远程添加github git@github.com:myname/oldrep.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
git remote rm origin
然后
git push -f
您需要检查原点,如果不存在则添加。
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。
试试这个命令,对我有用。
Rm -rf .git/