【问题标题】:How to clone all projects of a user in GitLab at once?如何一次在 GitLab 中克隆用户的所有项目?
【发布时间】:2020-09-06 01:01:21
【问题描述】:

当我安装一台新机器时,我想一次检出我存储在GitLab 的所有个人 Git 存储库。

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

【问题讨论】:

    标签: git gitlab migration clone


    【解决方案1】:

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

    • 使用read_api 范围创建personal access token
    • 安装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 个项目,请更改页面值

    【讨论】:

      猜你喜欢
      • 2015-05-19
      • 2016-08-25
      • 2013-11-27
      • 1970-01-01
      • 2021-10-17
      • 1970-01-01
      • 2022-01-03
      • 2021-09-09
      • 2023-04-10
      相关资源
      最近更新 更多