glab repo clone: Clone GitLab Repos in CI
glab repo clone clones a GitLab project by path, or every project under a group, authenticating with your token.
When a job needs another GitLab repo, glab repo clone uses the same token as the rest of the CLI, so you avoid embedding credentials in a git URL.
What it does
glab repo clone clones a project given its path (group/project). Given just a group or username it clones all accessible projects underneath. It uses the authenticated token, so private repos clone without hardcoding credentials in the remote URL.
Common usage
# clone a single project
glab repo clone mygroup/myproject
# clone every project in a group, keeping the namespace layout
glab repo clone mygroup --preserve-namespace
# pass extra git flags after --
glab repo clone mygroup/myproject -- --depth 1Options
| Flag | What it does |
|---|---|
| <group/project> | Path of the project to clone |
| <group> | Clone all accessible projects under the group |
| --preserve-namespace | Recreate the group directory structure |
| --paginate | Fetch all pages when cloning many projects |
| -- <git args> | Pass flags straight through to git clone |
In CI
glab repo clone relies on GITLAB_TOKEN (and GITLAB_HOST for self-managed), so authenticate once and reuse it. Add -- --depth 1 for a shallow clone to speed up jobs. For self-managed hosts set GITLAB_HOST or the clone resolves against gitlab.com.
Common errors in CI
"authentication required" means GITLAB_TOKEN is unset. "404 Project Not Found" means the path is wrong or the token cannot see it. "fatal: could not read Username for \"https://gitlab.com\"" means glab fell back to a plain git clone without a token; confirm glab is authenticated. A wrong GITLAB_HOST gives "no such host".