Help us learn about your current experience with the documentation. Take the survey.

通过上传清单文件导入多个仓库

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

GitLab 允许您基于清单文件导入所有必需的 Git 仓库, 就像 Android 仓库 使用的文件一样。 使用清单文件可以导入包含多个仓库的项目,例如 Android 开源项目 (AOSP)。

前提条件

  • 必须启用 清单导入源。 如果未启用,请要求您的 GitLab 管理员启用它。GitLab.com 默认启用清单导入源。
  • GitLab 必须使用 PostgreSQL 作为数据库,因为清单导入需要 子组 才能正常工作。 更多信息请参见 数据库要求
  • 在目标导入组中至少需要 Maintainer 角色。

清单格式

清单必须是大小不超过 1 MB 的 XML 文件。必须有一个包含 review 属性的 remote 标签,该属性包含指向 Git 服务器的 URL,并且每个 project 标签都必须有 namepath 属性。GitLab 通过结合 remote 标签中的 URL 和项目名称来构建仓库的 URL。 path 属性用于表示 GitLab 中的项目路径。

以下是清单文件的有效示例:

<manifest>
  <remote review="https://android.googlesource.com/" />

  <project path="build/make" name="platform/build" />
  <project path="build/blueprint" name="platform/build/blueprint" />
</manifest>

结果将创建以下项目:

GitLab 导入 URL
https://gitlab.com/YOUR_GROUP/build/make https://android.googlesource.com/platform/build
https://gitlab.com/YOUR_GROUP/build/blueprint https://android.googlesource.com/platform/build/blueprint

导入仓库

开始导入:

  1. 从您的 GitLab 仪表板选择 New project(新建项目)。
  2. 切换到 Import project(导入项目)选项卡。
  3. 选择 Manifest file(清单文件)。
  4. 向 GitLab 提供一个清单 XML 文件。
  5. 选择您要导入到的组(如果没有组,需要先创建一个)。
  6. 选择 List available repositories(列出可用仓库)。此时,您将被重定向到导入状态页面, 其中包含基于清单文件的项目列表。
  7. 导入方式:
    • 首次导入所有项目:选择 Import all repositories(导入所有仓库)。
    • 再次导入单个项目:选择 Re-import(重新导入)。指定新名称并再次选择 Re-import。重新导入会创建源项目的新副本。