我有我的项目在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远程rm来源 Git remote -v 它不会显示任何存储库名称 Git远程添加源git@github.com:用户名/myapp.git Git push origin master 它将启动流程并创建新分支。 你可以看到你的作品被推送到github。
其他回答
git remote rm origin
然后
git push -f
您得到这个错误是因为“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
我第一次使用Bitbucket时也遇到了同样的问题。
我的问题是我需要把origin这个词改成一些自定义的东西。我使用了应用程序的名称。所以:
git remote add AppName https://someone@bitbucket.org/somewhere/something.git
尝试删除第一个现有的起源,为了看到哪个现有的起源已经注册了bash,你可以启动下面的命令。
git remote -v
在您知道哪个版本的源已经注册到bash之后,您可以通过下面的命令来删除现有的源
git remote rm origin
一旦你删除了现有的原点,你可以在你的情况下通过以下命令添加新的原点。
git remote add origin git@github.com:myname/oldrep.git
一旦你在git中添加了你的origin,你就可以将你的本地提交推到远程的origin
git push -u origin --all
您需要检查原点,如果不存在则添加。
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。