项目需求,需要把git库从另外一个代码管理平台迁移到 新的代码管理平台,并且要保留原仓库的提交历史,这里用到了git两个命令:git clone --bare 旧仓库地址 / git push --mirror 新仓库地址:
1.从原地址克隆一份裸版本库
git clone --bare https://username:password@git.old.com/demo.git
--bare 创建的克隆版本库不包含工作区,直接就是版本库的内容,这样的版本库称为裸版本库。
这里username:password就是仓库对应的用户名密码,下面push也一样
2.进入到clone下来的仓库目录下
cd demo
3.通过--mirror推送到新的代码库
git push --mirror https://username:password@git.new.com/demo.git
该方式迁移仓库,保留了原有仓库的全部提交记录。