GLab — GitLab CLI
GLab (glab) is the official open-source command-line tool for GitLab, bringing GitLab workflows (issues, merge requests, CI/CD pipelines, releases, and more) directly to the terminal. It supports GitLab.com, GitLab Self-Managed, and GitLab Dedicated, with multi-instance authentication and automatic remote detection.
Key Capabilities
- Merge Requests & Issues: Create, list, review, and manage MRs and issues from the CLI. Examples:
glab mr list --assignee=@me,glab issue create -t "Title" --label bug - CI/CD: View, trace, and retry pipelines and jobs.
glab ci view,glab ci trace - Releases & Changelogs: Create releases and interact with the changelog API
- GitLab Duo: Ask AI questions about git via
glab duo ask - MCP Server: Experimental Model Context Protocol support via
glab mcp - Stacked Diffs: Create and manage stacked diffs with
glab stack - Repo Management: Clone repos, manage deploy keys, SSH keys, GPG keys, variables, tokens
Installation
brew install glab # macOS / Linux / WSL
brew upgrade glab # update
Binaries also available on the releases page. Requires GitLab 16.0+.
Authentication Methods
| Method | Command | Notes |
|---|---|---|
| OAuth (GitLab.com) | glab auth login → select Web |
Browser-based authorization |
| OAuth (Self-Managed) | Set client_id first, then glab auth login --hostname <host> |
Requires custom OAuth app |
| Personal Access Token | glab auth login --token xxx --hostname <host> |
Needs api + write_repository scopes |
| CI Job Token | GLAB_ENABLE_CI_AUTOLOGIN=true or manual --job-token |
Auto-detects in GitLab CI |
Token precedence: GITLAB_TOKEN env var → config.yml.
Configuration
- Global:
~/.config/glab-cli/config.yml(XDG-compliant) - Local (per-repo):
.git/glab-cli/config.yml - Per-host:
glab config set <key> <value> --host <hostname> - Set default instance:
glab config set -g host gitlab.example.com - Self-signed certs:
glab config set ca_cert /path/to/cert --host <host>orskip_tls_verify true
Important Environment Variables
| Variable | Purpose |
|---|---|
GITLAB_TOKEN |
Override stored credentials |
GITLAB_HOST |
Target a specific GitLab instance |
GITLAB_REPO |
Default repo for --repo commands |
GLAB_CONFIG_DIR |
Override config directory |
DEBUG=true |
Verbose logging (git commands, aliases, DNS) |
NO_PROMPT=true |
Disable interactive prompts |
Notable Design Details
- Written in Go, follows SemVer
- Adopted from Clement Sam’s original project in 2022; inspired by GitHub CLI and
lab lab(by zaquestion) provided the foundation for CI/CD commands likeci viewandci trace- Supports mTLS certificates for enterprise environments
- CI auto-login feature (GA) detects GitLab CI environment automatically
Source
- Raw: GLab — GitLab CLI
- Repository: https://gitlab.com/gitlab-org/cli