下载 GitLab 私有存储库 [英] Download a GitLab private repository
问题描述
我想使用 curl
在 GitLab 中下载我的私人存储库.我知道我可以使用 Gitlab API,但由于某种原因,它不起作用.
这可能吗?当我尝试这样做时,它总是返回登录页面.
这是可能的,只需按照以下步骤操作:
首先,您必须创建一个个人访问令牌":
转到
点击创建个人访问令牌"
页面将重新加载并保存您的新令牌.
确保将令牌保存在安全的地方,您将无法再次查看.
既然您有了个人访问令牌",您需要获取项目 ID 才能使用 API:
转到
(或者,您可以直接从其网页复制项目 ID)
现在您可以调用:
wget -O your_project.tar.gz https://gitlab.com/api/v4/projects/0000000/repository/archive?private_token=XXXXXXXXXXXXXXXXXXXXX
这会将您的项目下载为 .tar.gz
文件.
您可以通过将 &sha=...
参数添加到 url 来获取特定提交/标记的 tarball,例如:rel="nofollowapi/gitlabr.v4/projects/24470128/repository/archive?private_token=XXXXXXXXXXXXX&sha=606e81c69eff27eccbbc59a0546a9439780dff55
I want to use curl
to download my private repo in GitLab. I know I can use the Gitlab API, but for some reason, It doesn't work.
Is this possible? When I try to do it this way, it always returns the login page.
This is possible, just follow these steps:
First, you have to create a "Personal Access Token":
Enter a name for your "Personal Access Token".
Check "api Access the authenticated user's API"
Click "Create personal access token"
The page will reload and save your new token.
Make sure you save the token somewhere safe, you won't be able to view it again.
Now that you have your "Personal Access Token", you need to get your project id to use the API:
Go to https://gitlab.com/api/v4/projects?private_token=XXXXXXXXXXXXXXXXXXXX (replace the Xs with your new token)
Get your project's id from the json.
(alternatively you can just copy Project ID from it's web page)
Now you can call:
wget -O your_project.tar.gz https://gitlab.com/api/v4/projects/0000000/repository/archive?private_token=XXXXXXXXXXXXXXXXXXXX
And that'll download your project as a .tar.gz
file.
Edit: you can get tarball for specific commit/tag by adding &sha=...
parameter to url, like:
https://gitlab.com/api/v4/projects/24470128/repository/archive?private_token=XXXXXXXXXXXXX&sha=606e81c69eff27eccbbc59a0546a9439780dff55
这篇关于下载 GitLab 私有存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!