Florian Heinle
5 months
Claus-Theodor Riegg
2 years
Andreas Vöst
6 months
Moritz Kraus
7 months
Florian Heinle
10 months
Claus-Theodor Riegg
6 years
Florian Heinle
1 year
Claus-Theodor Riegg
2 years

HowTo: Clone and refresh all repos in a GitLab Group

Posted 5 months ago. Visible to the public.

If the project you're working on has, say, 39 repositories and counting in GitLab and you need all the repos checked out for some reason, here's how to do it.

Checking out all repos

  1. Create a personal access token for GitLab that has the API permissions. In your terminal, store this key in an env variable.
  2. For each group you want to check out:
    1. Create a new directory where you want all the checkouts to live.
    2. In GitLab, navigate to the Group's overview page so you can see the Group ID.
    3. In the directory you created before, run the oneliner that checks out the code.

For example:

$ TOKEN=gl_blablabla
$ GITLAB_URL=https://gitlab.com
$ mkdir awesome_microservice_project && cd awesome_microservice_project
$ mkdir devops && pushd devops
$ GROUP_ID=313373
$ for repo in $(curl -s --header "PRIVATE-TOKEN: your_private_token" $GITLAB_URL/api/v4/groups/$GROUP_ID | jq -r ".projects[].ssh_url_to_repo"); do git clone $repo; done;
$ popd
$ mkdir terraform && pushd terraform
$ GROUP_ID=313374
$ for repo in $(curl -s --header "PRIVATE-TOKEN: your_private_token" $GITLAB_URL/api/v4/groups/$GROUP_ID | jq -r ".projects[].ssh_url_to_repo"); do git clone $repo; done;

etc.

Refreshing all the repos

If you then need to pull changes made by your colleagues, this one liner will check out all the files

$ for repo in $(find . -type d -name .git -exec dirname {} \;); do pushd $repo; git pull; popd; done

gita

You could use the tool gita from github/nosarthur Show archive.org snapshot . This is available in the ubuntu repo.

  1. Run gita add * in the directory where the repos live on your machine.
  2. Run gita fetch, gita pull
Avatar
Florian Heinle
Last edit
4 months ago
Moritz Kraus
Tags
About this deck
We are makandra and do test-driven, agile Ruby on Rails software development.