完整迁移
完整的迁移git仓库,有利于后期的维护,因为git仓库里面包含了项目的各个分支,提交历史等
操作
克隆
从原地址(老仓库)克隆一份裸版本库
# 老仓库地址
git clone --bare https://github.com/username/project.git
然后到Git上创建一个新项目 名叫: newproject.git
推送
以镜像推送的方式上传代码到新的项目中
# 老项目地址
cd project.git
# 新仓库地址
git push --mirror https://github.com/username/newproject.git
完成迁移
完成了迁移,使用和平时用法一致
项目迁移成功之后,可以不用git clone,直接在旧的项目终端输入一条命令,本地代码的地址就会变成新代码的地址
git remote set-url origin https://github.com/username/newproject.git