今天公司需要切换一个git仓库地址,查了几个命令如下
git clone --mirror <旧的仓库地址>
cd <刚clone的文件夹>
git remote set-url origin <新的仓库地址>
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