1

When I install a new machine I would like to checkout all my personal Git repositories stored at GitLab at once.

I tried some tools like Gitlabber, but they focus on groups. Group namespaces are not the same as user namespaces in GitLab. I dont have a group for my projects.

pixelbrackets
  • 1,958
  • 19
  • 28

2 Answers2

4

Based on an answer by @dinesh-balasubramanian how to clone all repositories of a group in GitLab I wrote a command for this.

  • Create a personal access token with read_api scope
  • Install curl and jq
  • Run this command to get a list of all projects of a username, search for the SSH URLs of them and execute git clone with each result (replace the placeholders before)
    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;
    
    • Note: Gitlab returns a maximum of 100 items per page (20 items by default) - Change the page value if you have more than 100 projects
pixelbrackets
  • 1,958
  • 19
  • 28
0

Checkout this tool that I created using python shipped with docker, it will keep the group/subgroup tree structure and will clone/pull all repos that are not mirrored.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 11 '22 at 12:10
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31264590) – Simas Joneliunas Mar 15 '22 at 02:15