
需求背景现有需求将GitHub某开源仓库镜像到私有化部署的GitLab平台。解决项目引用开源组件时因网络问题直接从GitHub获取源码困难的问题。解决方案方法1利用 GitLab 的 Import project 功能前提条件GitLab 服务器可以正常连接 GitHub操作步骤打开GitLab选择【New project】– 【Import project】选择【Repo by URL】然后填写GitHub上的仓库的Clone链接。开源公开仓库 Username和Password不需要填私有的个人GitHub非公开仓库需要填写方法2手动镜像前提条件一个可以同时正常访问 GitHub 和私有 GitLab 平台的个人PC并已经安装Git工具。去GitLab平台创建一个空仓库注意必须取消勾选Initialize repository with a README记下这个仓库地址假设为gitgitlab.yourcompany.com:third_party/c-periphery.git在本机克隆 GitHub 的 mirror并推送到私有 GitLabgitclone--mirrorhttps://github.com/vsergeev/c-periphery.gitcdc-periphery.gitgitpush--mirrorgitgitlab.yourcompany.com:third_party/c-periphery.git# 这一步会把 所有分支 tag refs 一次性推过去。