Git系列文章目录
前言
有时Gitlab由于权限问题,不支持链接直接迁移,这时就需要进行Git 命令方式进行迁移。
一、镜像迁移
将源端仓库,镜像克隆到本地,再镜像推送到新建空白的目标仓库。
$ git clone --mirror https://github.com/containers/bubblewrap.git # 克隆源端仓库
$ git push --mirror https://github.com/user/bubblewrap.git # 推送到目标仓库
二、裸仓库迁移
将源端仓库,裸仓库克隆到本地,再镜像推送到新建空白的目标仓库。
和镜像仓库对比,克隆下来的裸仓库中只有 .git 内容,是没有工作目录的。
$ git clone --bare https://github.com/containers/bubblewrap.git # 克隆源端裸仓库
$ git push --mirror https://github.com/user/bubblewrap.git # 推送到目标仓库
三、直接克隆仓库迁移
$ git clone https://github.com/containers/bubblewrap.git && cd bubblewrap # 若本地没有仓库,则直接 clone 仓库到本地
$ git pull && git pull --tags # 若本地已有仓库,则拉取分支和标签
$ git remote set-url origin https://github.com/user/bubblewrap.git # 设置目标仓库url
$ git push && git push --tags # 推送分支和标签