# GitLab CLI (glab) `glab` is the official command-line interface for [[GitLab]], maintained by the GitLab core team since the project was donated by community maintainer Clement Sam in 2022. It mirrors the role that `gh` plays for [[GitHub]]: a fast, scriptable terminal interface to repositories, merge requests, issues, pipelines, releases, and the GraphQL/REST APIs ; without leaving your shell. It is written in [[Go]] and ships as a single static binary, which makes it trivial to install on Linux, macOS, and Windows (including [[Windows Subsystem for Linux (WSL)]]). ## What You Can Do With It - **Repos**: clone, fork, view, set defaults - **Merge requests**: create, list, view, approve, merge, rebase, check CI status - **Issues**: create, list, comment, close, link to MRs - **Pipelines (CI/CD)**: trigger, watch live, retry, view job logs, download artifacts - **Releases**: create, upload assets, generate notes - **Snippets**: create and share - **API**: raw REST and GraphQL calls (`glab api graphql -f [email protected]`) - **Auth**: `glab auth login` ; supports gitlab.com, self-hosted, and dedicated instances ## Installation The project supports a wide range of channels: ```bash # Homebrew (macOS, Linux) brew install glab # Arch Linux pacman -S glab # Debian/Ubuntu (.deb from releases) # Fedora (dnf install glab) # Snap, Scoop, MacPorts # Or just download the binary # https://gitlab.com/gitlab-org/cli/-/releases ``` For [[Windows Subsystem for Linux (WSL)]] specifically, the Linux install path is the simplest: install via the distro's package manager or `brew` if you have [[Homebrew]] on Linux. ## Common Patterns ```bash # Authenticate (per host) glab auth login --hostname gitlab.com # Open the current MR in your browser glab mr view --web # Create an MR from current branch with auto-fill from commits glab mr create --fill --remove-source-branch # Watch a pipeline live glab ci status --live # Run an arbitrary GraphQL query glab api graphql -f query='{ currentUser { username } }' ``` ## glab vs gh ([[GitHub]] CLI) The two are intentionally similar in shape. Most subcommands map 1:1 (`mr` ↔ `pr`, `ci` ↔ `run`/`workflow`). Differences come from each platform's model: GitLab pipelines are richer than [[GitHub Actions]] in places (parent-child pipelines, dynamic includes); GitHub's PR review flow has more dedicated CLI affordances. If you switch between platforms, alias the shared verbs you use most so muscle memory transfers. ## References - Documentation: https://docs.gitlab.com/cli/ - Source: https://gitlab.com/gitlab-org/cli - Installation: https://gitlab.com/gitlab-org/cli/#installation ## Related - [[GitLab]] - [[GitHub]] - [[Go]] - [[Homebrew]] - [[Windows Subsystem for Linux (WSL)]] - [[Continuous Integration (CI)]]