glab - GitLab CLI
Work seamlessly with GitLab from the command line.
glab is a CLI tool for GitLab, written in Go. It follows the same interface patterns as the GitHub CLI (gh), providing a familiar experience for managing merge requests, issues, pipelines, repositories, and more.
Documentation: philipkram.github.io/Gitlab-CLI
Installation
Homebrew (macOS & Linux)
brew tap PhilipKram/tap https://github.com/PhilipKram/Gitlab-CLI
brew install PhilipKram/tap/glab
Binary releases
Download pre-built binaries for Linux, macOS, and Windows (amd64/arm64) from the releases page.
Go install
go install github.com/PhilipKram/gitlab-cli@latest
Build from source
git clone https://github.com/PhilipKram/Gitlab-CLI.git
cd Gitlab-CLI
make build
# Binary available at ./bin/glab
Authentication
Interactive login (recommended)
Just run glab auth login and follow the prompts — the same experience as gh auth login:
$ glab auth login
? What GitLab instance do you want to log into?
[1] gitlab.com
[2] GitLab Self-managed
Choice: 1
? What is your preferred protocol for Git operations on this host?
[1] HTTPS
[2] SSH
Choice: 1
? How would you like to authenticate glab?
[1] Login with a web browser
[2] Paste a token
Choice: 1
? OAuth Application ID: <your-app-id>
! Opening gitlab.com in your browser...
- Waiting for authentication...
- glab config set -h gitlab.com git_protocol https
✓ Logged in to gitlab.com as username
OAuth (browser-based login)
Authenticate via OAuth in the browser. You first need to create an OAuth application
in your GitLab instance under Settings > Applications with:
- Redirect URI:
http://localhost:7171/auth/redirect
- Scopes:
api, read_user, write_repository, openid, profile
# Interactive OAuth login
glab auth login --web --client-id <your-app-id>
# OAuth with a self-hosted instance
glab auth login --web --client-id <your-app-id> --hostname gitlab.example.com
The CLI starts a local server on port 7171, opens your browser for authorization, and
automatically exchanges the code for a token using PKCE.
Token-based login
# Login with a personal access token
glab auth login --token glpat-xxxxxxxxxxxxxxxxxxxx
# Login to a self-hosted GitLab instance
glab auth login --hostname gitlab.example.com --token glpat-xxxx
# Pipe a token from a file or secret manager
glab auth login --stdin < token.txt
# Check authentication status
glab auth status
# Environment variable authentication
export GITLAB_TOKEN="glpat-xxxxxxxxxxxxxxxxxxxx"
Required token scopes: api, read_user, write_repository
Auth login flags
| Flag |
Description |
--hostname |
GitLab hostname (default: gitlab.com) |
--token, -t |
Personal access token |
--web, -w |
Authenticate via OAuth in the browser |
--client-id |
OAuth application ID (required with --web) |
--git-protocol, -p |
Preferred git protocol: https or ssh |
--stdin |
Read token from standard input |
Per-host configuration
Store OAuth settings per host so you don't need to pass them every time:
# Store OAuth client ID for a self-hosted instance
glab config set client_id <app-id> --host gitlab.example.com
# Store custom redirect URI (default: http://localhost:7171/auth/redirect)
glab config set redirect_uri http://localhost:8080/callback --host gitlab.example.com
# Store custom OAuth scopes
glab config set oauth_scopes "api read_user write_repository" --host gitlab.example.com
Global Flags
| Flag |
Description |
--repo, -R |
Select a GitLab repository using HOST/OWNER/REPO format |
The --repo flag lets you target any project without being in its git repository:
glab issue list -R gitlab.example.com/owner/repo
glab mr list --state opened -R gitlab.example.com/group/project
When no --repo is specified, glab resolves the host from the git remote. If the remote isn't a GitLab host, it falls back to the default host, then to the first authenticated host.
Commands
Core Commands
| Command |
Description |
glab auth |
Authenticate glab and git with GitLab |
glab mr |
Manage merge requests |
glab issue |
Manage issues |
glab repo |
Manage repositories |
CI/CD Commands
| Command |
Description |
glab pipeline |
Manage pipelines and CI/CD |
glab release |
Manage releases |
Additional Commands
| Command |
Description |
glab snippet |
Manage snippets |
glab label |
Manage labels |
glab project |
Manage projects |
Utility Commands
| Command |
Description |
glab api |
Make authenticated API requests |
glab browse |
Open project in browser |
glab config |
Manage configuration |
glab completion |
Generate shell completion scripts |
Usage Examples
Merge Requests
glab mr create --title "Add feature" --description "Details" --draft
glab mr list --state opened
glab mr view 123
glab mr merge 123 --squash
glab mr approve 123
glab mr checkout 123
glab mr diff 123
glab mr comment 123 --body "Looks good!"
glab mr comment 123 --body "Consider refactoring this" --file "cmd/mr.go" --line 42
glab mr comment 123 --body "Good removal" --file "cmd/mr.go" --old-line 10
Issues
glab issue create --title "Bug report" --label bug --assignee @user1
glab issue list --state opened --author johndoe
glab issue view 42
glab issue close 42
glab issue comment 42 --body "Fixed in !123"
Pipelines
glab pipeline list
glab pipeline run --ref main
glab pipeline view 12345
glab pipeline jobs 12345
glab pipeline cancel 12345
Repositories
glab repo clone owner/repo
glab repo create my-project --public --init
glab repo fork owner/repo --clone
glab repo view
glab repo list --owner my-group
Configuration
glab config set protocol ssh
glab config set editor vim
glab config list
# Per-host config
glab config set client_id <app-id> --host gitlab.example.com
glab config get client_id --host gitlab.example.com
Direct API Access
glab api projects
glab api users --method GET
glab api projects/:id/issues --method POST --body '{"title":"Bug"}'
# Target a specific host
glab api '/projects?membership=true' --hostname gitlab.example.com
Configuration
Configuration is stored in ~/.config/glab/. Override with GLAB_CONFIG_DIR.
Global keys
| Key |
Description |
Default |
editor |
Preferred text editor |
- |
pager |
Preferred pager |
- |
browser |
Preferred web browser |
- |
protocol |
Git protocol (https/ssh) |
https |
git_remote |
Default git remote name |
origin |
Per-host keys (use with --host)
| Key |
Description |
Default |
client_id |
OAuth application ID |
- |
redirect_uri |
OAuth redirect URI |
http://localhost:7171/auth/redirect |
oauth_scopes |
OAuth scopes |
openid profile api read_user write_repository |
protocol |
Git protocol for this host |
- |
api_host |
API hostname override |
- |
Environment Variables
| Variable |
Description |
GITLAB_TOKEN |
Authentication token |
GLAB_TOKEN |
Authentication token (alternative) |
GITLAB_HOST |
Default GitLab hostname |
GLAB_CONFIG_DIR |
Configuration directory |
Releasing
Releases are automated via GoReleaser and GitHub Actions.
To create a release:
git tag v0.1.0
git push origin v0.1.0
This will:
- Run tests
- Build cross-platform binaries (linux/darwin/windows, amd64/arm64)
- Create a GitHub Release with archives and checksums
- Update the Homebrew formula in the
HomebrewFormula directory
- Publish deb/rpm packages
Shell Completions
# Bash
source <(glab completion bash)
# Zsh
glab completion zsh > "${fpath[1]}/_glab"
# Fish
glab completion fish | source
License
MIT