{{< details >}}
- Tier: 基础版,专业版,旗舰版
- Offering: JihuLab.com,私有化部署
{{< /details >}}
您可以通过提供 Git URL 导入现有的仓库。您不能通过这种方式导入极狐GitLab 议题和合并请求。其他方法提供更完整的导入方式。
如果仓库太大,导入可能会超时。
您可以通过以下方式导入您的 Git 仓库:
前提条件
{{< history >}}
- 对维护者角色的要求在极狐GitLab 16.0 中引入,并在极狐GitLab 15.11.1 和极狐GitLab 15.10.5 中进行了回溯。
{{< /history >}}
- 必须启用 通过 URL 导入源仓库。如果未启用,请请求您的极狐GitLab 管理员启用它。通过 URL 导入源仓库在 JihuLab.com 上默认启用。
- 至少需要导入目标群组的维护者角色。
- 如果导入私有仓库,则可能需要用于访问源仓库的访问令牌而不是密码。
使用 UI 导入项目
- 在左侧边栏的顶部,选择 创建新的 ({{< icon name=”plus” >}}) 和 新项目/仓库。
- 选择 导入项目。
- 选择 通过 URL 导入仓库。
- 输入 Git 仓库 URL。
- 完成剩余字段。从私有仓库导入时需要用户名和密码(或访问令牌)。
- 选择 创建项目。
您的新项目将显示。
导入超时项目
大型仓库的导入可能在三小时后超时。 要导入超时项目:
-
克隆仓库。
git clone --mirror https://example.com/group/project.git
--mirror
选项确保所有分支、标签和引用都被复制。 -
添加新的远程仓库。
cd repository.git git remote add new-origin https://gitlab.com/group/project.git
-
将所有内容推送到新的远程仓库。
git push --mirror new-origin
使用 API 导入项目
您可以使用 项目 API 导入 Git 仓库:
curl --location "https://gitlab.example.com/api/v4/projects/" \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-token>' \
--data-raw '{
"description": "New project description",
"path": "new_project_path",
"import_url": "https://username:password@example.com/group/project.git"
}'
某些提供商不允许使用密码,而是需要访问令牌。