【发布时间】:2021-12-04 15:19:36
【问题描述】:
在研究如何通过 GitLab API 将 Git 存储库导入 GitLab 时,我的搜索结果似乎被使用 ssh 将 GitHub 存储库镜像到 GitLab 的方法污染了。我正在尝试在自托管 GitLab 服务器上执行相当于转到:http://127.0.0.1/projects/new#import_project 的 CLI/Bash,然后输入:
http://www.somegit.com/somegituser/somegitrepository.git,如下图所示:
除了使用 GitLab API(和个人访问令牌)。于是我看了the GitLab documentation就跑了:
curl --request POST --header "PRIVATE-TOKEN: $personal_access_token" "http://127.0.0.1/api/v4/projects/1/export" \
--data "upload[http_method]=PUT" \
--data-urlencode "upload[url]=http://www.somegit.com/someuser/somegithubrepository.git"
返回:
{"message":"202 Accepted"}(base)
但是,存储库不会出现在 GitLab 服务器中。因此,我想知道:如何使用导入方法和 GitLab API 将任意公共 git 存储库添加到自托管 GitLab 服务器(不为 GitLab 使用 ssh)?
【问题讨论】:
-
是否有意在 curl 中使用
exportapi 而不是importapi? -
不,这是无意的,在撰写本文时我并不知道这两个选项的存在。