如何一次在GitLab中克隆用户的所有项目?

问题描述 投票:0回答:1

[安装新机器时,我想立即检出存储在GitLab的所有个人Git存储库。

我尝试了一些工具,例如Gitlabber,但它们专注于组。 GitLab中的Group namespaces are not the same as user namespaces。我的项目没有小组。

git gitlab migration clone
1个回答
2
投票

基于@ dinesh-balasubramanian的回答,clone all repositories of a group in GitLab我为此编写了一个命令。

  • personal access token范围创建read_api
  • 安装curljq
  • 运行此命令以获取用户名的所有项目的列表,搜索它们的SSH URL,并对每个结果执行git clone(在之前替换占位符)
    for repo in $(curl -H "PRIVATE-TOKEN: XXXX-YOUR-TOKEN-XXXX" "https://gitlab.com/api/v4/users/XXXX-YOUR-USERNAME-XXXX/projects/?page=1&per_page=100" | jq .[].ssh_url_to_repo | tr -d '"'); do git clone $repo; done;
    
    • 注意:Gitlab每页最多返回100个项目(20 items by default-如果您有100个以上的项目,请更改页面值] >>
© www.soinside.com 2019 - 2024. All rights reserved.