度娘了一堆git仓库迁移的内容,一个个都比较麻烦,而且本地下了代码,还要删去库地址,再切换到新库的地址上传。
一般这种操作都只是master分支,其他分支还要一个一个来,后来在51CTO上找了一个文章,简单明了,一下就全搞定了。
包括所有的分支、标签、日志,一个不少。
当然账号对应的事就没办法了。
四行命令:
git clone --mirror <URL to my OLD repo location>
cd <New directory where your OLD repo was cloned>
git remote set-url origin <URL to my NEW repo location>
git push -f origin
如果 git push -f origin 报错 出现failed to push some refs to git
可以通过以下方式解决
git pull --rebase origin master
如果还是无法推动,那么在代码仓库控制面板,取消master分支保护功能、
仅三行命令即可完成:
git clone --bare http://域名/分组/仓库名称.git
cd 仓库名称.git
git push --mirror http://新域名/新分组/新仓库名称.git