Command Palette

Search for a command to run...

GitHubGitHub

GitLab CLI Installation Guide

Install GitLab CLI 1.124 on Linux, macOS and Windows, authenticate with OAuth or a token, and manage merge requests, pipelines, runners and releases from your terminal.

GitLab CLI (glab) is the official GitLab command-line tool. It handles merge requests, issues, pipelines, runners and releases — and it detects the GitLab instance from the remotes in your working directory.

System Requirements

  • A 64-bit operating system: Linux, macOS or Windows
  • git on your PATH
  • A GitLab.com, GitLab Dedicated or GitLab Self-Managed instance on GitLab 16.0 or later — some commands need even newer versions

Installation Instructions

Homebrew (officially supported)

# macOS, Linux and Windows (through WSL)
brew install glab
 
# Update later with
brew upgrade glab
 
glab --version

Authentication

glab supports OAuth, personal access tokens and CI job tokens.

# Interactive login
glab auth login
 
# Log in to a self-managed instance
glab auth login --hostname gitlab.example.com
 
# Non-interactive login with a token
echo "$GITLAB_TOKEN" | glab auth login --stdin
 
# Check the current state
glab auth status
 
# Log out
glab auth logout
# In CI, the token is simply an environment variable
export GITLAB_TOKEN=glpat-xxxxxxxxxxxx
export CI_SERVER_URL=https://gitlab.com
VariablePurpose
GITLAB_TOKENToken used for API requests
GITLAB_HOSTDefault instance URL
GLAB_CONFIG_DIRWhere the configuration is stored
GLAB_DEBUGSet to true for verbose logging, including the underlying git commands

Everyday Commands

Merge Requests

# Create a merge request
glab mr create --title "Add login" --description "Closes #42" --source-branch feature/login
 
# List, view and check out
glab mr list --assignee=@me
glab mr list --reviewer=@me
glab mr view 235
glab mr checkout 235
 
# Review and merge
glab mr approve 235
glab mr merge 235 --squash --remove-source-branch

Issues

# Create and list
glab issue create -m release-2.0.0 -t "My title here" --label important
glab issue list --assignee=@me
 
# Update and close
glab issue update 42 --label "needs review"
glab issue close 42

Pipelines and Jobs

# List and inspect
glab pipeline list
glab pipeline view 12345
glab pipeline status
 
# Follow a job log
glab ci list
glab ci view 98765
glab ci trace 98765
 
# Retry a failed job
glab ci retry 98765

Repositories and Releases

# Repository
glab repo clone owner/repo
glab repo fork owner/repo
glab repo view
 
# Releases and changelogs
glab release create v1.2.0 --notes "Bug fixes"
glab changelog generate

Runners, Agents and Variables

# Runners
glab runner list
glab runner create --name my-runner --executor docker
 
# GitLab Agents for Kubernetes
glab cluster agent list
 
# Project and group variables
glab variable set LOG_LEVEL --scope project --value debug
glab variable list

GitLab Duo in the Terminal

# Ask GitLab Duo about the codebase
glab duo cli
 
# Or a one-off question
glab duo chat "explain this module"

Troubleshooting

Best Practices

  1. Install with Homebrew — it is the officially supported method and always has the current release.
  2. Use a scoped token: read_api for read-only automation, api only when you really need to write.
  3. Set GITLAB_TOKEN in CI instead of running the interactive login.
  4. Turn on GLAB_DEBUG=true when something behaves strangely — it shows the git commands and the API calls.
  5. Use glab api for anything the CLI does not wrap.
  6. Use glab runner and glab cluster agent to manage runners and agents instead of the web UI.
  7. Pin the CLI version in CI images so a new release cannot change your pipeline.
  8. Never commit a token — use CI variables and masked, protected project variables.

Next Steps