Skip to content

Instantly share code, notes, and snippets.

@vxavictor513
Last active May 26, 2025 06:55
Show Gist options
  • Save vxavictor513/a2e3ad5b2425ee8d609feb835eabb18f to your computer and use it in GitHub Desktop.
Save vxavictor513/a2e3ad5b2425ee8d609feb835eabb18f to your computer and use it in GitHub Desktop.

Revisions

  1. vxavictor513 revised this gist May 26, 2025. 1 changed file with 25 additions and 15 deletions.
    40 changes: 25 additions & 15 deletions gitlab-clone-group.md
    Original file line number Diff line number Diff line change
    @@ -1,44 +1,54 @@
    # Clone A GitLab Group
    # Clone a GitLab Group

    When working with a distributed system made of many code repositories, it is tedious to clone each repository manually.

    Below is how you could clone an entire GitLab group of repositories in one go.

    1. Install GitLab CLI `glab` following the installation steps in https://gitlab.com/gitlab-org/cli/#installation.
    ## 1. Install `glab`

    2. Create a personal access token
    Install the GitLab CLI `glab` by following the instructions at https://gitlab.com/gitlab-org/cli/#installation.

    3. If the GitLab instance has self-signed certificate, set to skip TLS or install the necessary certificates.
    ## 2. Create a Personal Access Token

    Generate a personal access token with at least the api and write_repository scopes from your GitLab instance.

    ## 3. Configure TLS (if needed)

    If your GitLab instance uses a self-signed certificate, either install the appropriate certificates or configure glab to skip TLS verification.

    ```sh
    glab config set skip_tls_verify true --host gitlab.wltheng.com
    glab config set skip_tls_verify true --host gitlab.example.com
    ```

    4. Authenticate via `glab` auth login. Below is a sample.
    ## 4. Authenticate with GitLab

    Authenticate using `glab auth login`. Here’s a sample session:

    ```sh
    $ glab auth login
    ? What GitLab instance do you want to sign in to? GitLab Self-Managed or GitLab Dedicated instance
    ? GitLab hostname: gitlab.wltheng.com
    ? API hostname: gitlab.wltheng.com
    - Signing into gitlab.wltheng.com
    ? GitLab hostname: gitlab.example.com
    ? API hostname: gitlab.example.com
    - Signing into gitlab.example.com
    ? How would you like to sign in? Token
    Tip: generate a personal access token at https://gitlab.wltheng.com/-/user_settings/personal_access_tokens?scopes=api,write_repository.
    Tip: generate a personal access token at https://gitlab.example.com/-/user_settings/personal_access_tokens?scopes=api,write_repository.
    The minimum required scopes are 'api' and 'write_repository'.
    ? Paste your authentication token: **************************
    ? Choose default Git protocol: SSH
    ? Choose host API protocol: HTTPS
    - glab config set -h gitlab.wltheng.com git_protocol ssh
    - glab config set -h gitlab.example.com git_protocol ssh
    ✓ Configured Git protocol.
    - glab config set -h gitlab.wltheng.com api_protocol https
    - glab config set -h gitlab.example.com api_protocol https
    ✓ Configured API protocol.
    ✓ Logged in as johndoe
    ✓ Configuration saved to /Users/johndoe/.config/glab-cli/config.yml
    ```

    5. Use `glab repo clone -g <group> --paginate` to clone a group.
    ## 5. Clone the Group

    Use the following command to clone all repositories under a GitLab group.

    ```sh
    # This clones all repositories under https://gitlab.wltheng.com/foo
    GITLAB_HOST=gitlab.wltheng.com glab repo clone -g foo --paginate
    # This clones all repositories under https://gitlab.example.com/foo
    GITLAB_HOST=gitlab.example.com glab repo clone -g foo --paginate
    ```
  2. vxavictor513 revised this gist May 26, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gitlab-clone-group.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Cloning GitLab Group
    # Clone A GitLab Group

    When working with a distributed system made of many code repositories, it is tedious to clone each repository manually.

  3. vxavictor513 revised this gist May 26, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gitlab-clone-group.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ When working with a distributed system made of many code repositories, it is ted

    Below is how you could clone an entire GitLab group of repositories in one go.

    1. Install GitLab CLI `glab` following installation steps in https://gitlab.com/gitlab-org/cli/#installation.
    1. Install GitLab CLI `glab` following the installation steps in https://gitlab.com/gitlab-org/cli/#installation.

    2. Create a personal access token

  4. vxavictor513 created this gist May 26, 2025.
    44 changes: 44 additions & 0 deletions gitlab-clone-group.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    # Cloning GitLab Group

    When working with a distributed system made of many code repositories, it is tedious to clone each repository manually.

    Below is how you could clone an entire GitLab group of repositories in one go.

    1. Install GitLab CLI `glab` following installation steps in https://gitlab.com/gitlab-org/cli/#installation.

    2. Create a personal access token

    3. If the GitLab instance has self-signed certificate, set to skip TLS or install the necessary certificates.

    ```sh
    glab config set skip_tls_verify true --host gitlab.wltheng.com
    ```

    4. Authenticate via `glab` auth login. Below is a sample.

    ```sh
    $ glab auth login
    ? What GitLab instance do you want to sign in to? GitLab Self-Managed or GitLab Dedicated instance
    ? GitLab hostname: gitlab.wltheng.com
    ? API hostname: gitlab.wltheng.com
    - Signing into gitlab.wltheng.com
    ? How would you like to sign in? Token
    Tip: generate a personal access token at https://gitlab.wltheng.com/-/user_settings/personal_access_tokens?scopes=api,write_repository.
    The minimum required scopes are 'api' and 'write_repository'.
    ? Paste your authentication token: **************************
    ? Choose default Git protocol: SSH
    ? Choose host API protocol: HTTPS
    - glab config set -h gitlab.wltheng.com git_protocol ssh
    ✓ Configured Git protocol.
    - glab config set -h gitlab.wltheng.com api_protocol https
    ✓ Configured API protocol.
    ✓ Logged in as johndoe
    ✓ Configuration saved to /Users/johndoe/.config/glab-cli/config.yml
    ```

    5. Use `glab repo clone -g <group> --paginate` to clone a group.

    ```sh
    # This clones all repositories under https://gitlab.wltheng.com/foo
    GITLAB_HOST=gitlab.wltheng.com glab repo clone -g foo --paginate
    ```