gitgitlab

In Gitlab - How can I clone all the repos under a certain organization?


I'm trying to clone all the repos under a certain organization called orgA. They have over 100+ repos with groups, subgroups etc.

I'm trying to use GitLab's CLI tool to clone all the repos, but the glab clone command is for a single group within the org. Not the entire org. So the following doesn't do the job: glab repo clone -g <group-id> -p --paginate

I do not wish to use a thirdparty tool to do this, only curl or glab

How can I simply clone an entire org?

Thanks


Solution

  • Turned out to be simple with an in liner shell script:

    glab api /groups | jq ".[].id" | xargs -I {} glab repo clone -g {} -p --paginate
    
    1. The glab api /groups makes an authenticate request to Gitlab's groups API to get all the groups related to an org.
    2. We pipe the json response to jq to extract the ids of those groups.
    3. Lastly, we execute glab repo clone command for each of those groups ids using xargs