git 仓库迁移的方法
一般我们要做迁移,需要保留原先的commit记录,普通的新建仓库&拷贝是行不通的,会丢失掉log。
这里采用git push --mirror 。
流程是:先将旧仓库的bare clone到本地,然后在去远端创建一个新仓库,最后将旧仓库的镜像推到新仓库中。
具体操作流程
1、git clone --bare 旧仓库地址
得到 oldProject.git
2、去新的git服务器上创建仓库
3、进入到旧仓库git中,将镜像推到新仓库中
cd oldProject.git
git push --mirror 新仓库地址
4、删除本地代码
cd..
rm -rf oldProject.git