项目中遇到git仓库迁移,很常见。如何把一个项目中全部的分支,tag等迁移到另外一个仓库地址,须要执行一个特别的克隆命令,而后镜像push到新的仓库地址。具体步骤以下:
1.打开命令行工具
2.以bare的方式克隆老的仓库git
git clone --bare https://github.com/exampleuser/old-repository.git
3.镜像push到新的仓库地址github
cd old-repository.git git push --mirror https://github.com/exampleuser/new-repository.git
4.在电脑中删掉老得仓库,把新的仓库从新拉下来工具
cd .. rm -rf old-repository.git
原文连接命令行