GitLab CLI (glab) Cheat Sheet

glab is the official GitLab CLI. It covers merge requests, issues, CI/CD pipelines, releases, repositories, CI/CD variables and the REST/GraphQL API, all from the terminal.

External Resources

Table of contents

  1. Installation
    1. Homebrew (macOS, Linux, WSL)
    2. Binary / from source
    3. Shell completion
  2. Authentication
    1. Login
    2. Status / logout
    3. auth login flags
    4. Tokens & OAuth notes
    5. Docker / container registry
  3. Configuration
    1. Commands
    2. Config file locations (first found wins)
    3. Common keys
    4. Self-managed / TLS
    5. Useful environment variables
  4. Common Flags & Conventions
  5. Merge Requests (glab mr)
    1. Create
    2. List
    3. View / diff / checkout
    4. Update
    5. Review, approve, merge
    6. Lifecycle
  6. Issues (glab issue)
    1. Create
    2. List
    3. View / update / comment / close
    4. Incidents & work items
  7. CI/CD Pipelines (glab ci)
    1. Run & watch
    2. Jobs
    3. Inspect & list
    4. Lint & config
    5. Cleanup
    6. Schedules (glab schedule, aliases sched, skd)
  8. CI/CD Variables (glab variable, alias var)
  9. Repositories (glab repo, alias project)
    1. Clone
    2. Create / fork / delete
    3. Browse / search
    4. Members, mirrors, remotes
  10. Releases (glab release)
    1. Changelog
  11. API (glab api)
  12. Labels, Milestones & Iterations
  13. Keys, Tokens & Access
  14. Snippets, Packages & Registries
  15. Runners, Clusters & Infrastructure
  16. Stacked Diffs (glab stack, experimental)
  17. Aliases
  18. Misc
  19. GitLab CI Usage
  20. Scripting Recipes

Installation

Homebrew (macOS, Linux, WSL)

brew install glab                  # Install
brew upgrade glab                  # Upgrade
glab version                       # Print version and build commit (alias: glab v)
glab check-update                  # Check for a newer release (alias: glab update)
glab whatsnew                      # Show release notes for the installed version
glab whatsnew --since v1.80.0      # Release notes since a version

Binary / from source

# Binaries: https://gitlab.com/gitlab-org/cli/-/releases
git clone https://gitlab.com/gitlab-org/cli.git && cd cli
make build                         # Requires make + Go (version in go.mod)
make install                       # Installs to $GOPATH/bin
export PATH=$PWD/bin:$PATH         # If $GOPATH/bin is not on PATH

glab officially supports GitLab 16.0+. Some commands need newer versions.

Shell completion

# zsh (current shell)
source <(glab completion -s zsh); compdef _glab glab
# zsh (persistent)
echo "autoload -U compinit; compinit" >> ~/.zshrc
glab completion -s zsh > "${fpath[1]}/_glab"
# bash
glab completion -s bash > /etc/bash_completion.d/glab
# fish
glab completion -s fish > ~/.config/fish/completions/glab.fish
# PowerShell
glab completion -s powershell | Out-String | Invoke-Expression

Homebrew installs completions automatically.


Authentication

Login

glab auth login                                    # Interactive (OAuth or token)
glab auth login --web                              # OAuth in the browser (skip the prompt)
glab auth login --device                           # OAuth device flow (no browser, GitLab 17.9+)
glab auth login --stdin < token.txt                # Personal access token from a file
glab auth login --hostname gitlab.example.com --stdin < token.txt   # Self-managed
glab auth login --hostname gitlab.example.com --token glpat-xxx     # Avoid on shared machines
glab auth login --hostname gitlab.example.com --web --setup-git-credential-helper

Status / logout

glab auth status                       # Current host
glab auth status --all                 # All configured hosts
glab auth status --hostname gitlab.example.com
glab auth status --show-token          # Print the token
glab auth status --all --output json
glab auth logout --hostname gitlab.example.com

auth login flags

| Flag | Description | |——|————-| | --hostname | GitLab host (default gitlab.com) | | -t, --token | Personal access token | | --stdin | Read token from stdin | | --web / --device | OAuth web / device flow | | -j, --job-token | CI job token | | -a, --api-host | API host if different from hostname (e.g. gitlab.example.org:3443) | | -p, --api-protocol | https | http | | -g, --git-protocol | ssh | https | http | | --ssh-hostname | SSH host if different | | --container-registry-domains | Comma-separated registry domains | | --setup-git-credential-helper | Configure glab as Git credential helper | | --insecure-storage | Store token in plaintext config instead of the OS keyring |

Tokens & OAuth notes

  • PAT scopes required: api and write_repository.
  • Self-managed OAuth app: redirect URI http://localhost:7171/auth/redirect, Confidential unchecked, scopes openid profile read_user write_repository api. Then:
    glab config set client_id <CLIENT_ID> --host gitlab.example.com
    glab auth login --hostname gitlab.example.com
    
  • Credentials go to the OS keyring (macOS Keychain) by default. Plaintext is used when no keyring exists, with --insecure-storage, or in CI.
  • Token resolution order: GITLAB_TOKEN → GITLAB_ACCESS_TOKEN → OAUTH_TOKEN (trusted hosts only) → stored credential → CI_JOB_TOKEN (when CI auto-login is on).

Docker / container registry

glab auth configure-docker             # Configure Docker to use glab as credential helper
glab auth docker-helper                # Docker credential helper entry point

Configuration

Commands

glab config set editor vim                         # Local (repo) or global if outside a repo
glab config set check_update false --global        # Global (-g)
glab config set token xxxxx --host gitlab.com      # Per host
glab config get editor
glab config get glamour_style --host gitlab.com
glab config edit                                   # Open config in editor
glab config path                                   # Show config file path
glab config set -g host gitlab.example.com         # Default host outside repos

Config file locations (first found wins)

| Order | Path | |——-|——| | 1 | $GLAB_CONFIG_DIR/config.yml | | 2 | ~/.config/glab-cli/config.yml (legacy) | | 3 | $XDG_CONFIG_HOME/glab-cli/config.yml | | 4 | $XDG_CONFIG_DIRS/glab-cli/config.yml (default /etc/xdg/glab-cli/config.yml) |

  • macOS XDG default: ~/Library/Application Support/glab-cli/config.yml
  • Per-repo config: .git/glab-cli/config.yml
  • Per-host keys (--host) always live in the global file.

Common keys

| Key | Description | Env var | |—–|————-|———| | host | Default host (gitlab.com) | GITLAB_HOST | | token | Access token (per host) | GITLAB_TOKEN | | api_host | API host (per host) | GITLAB_API_HOST | | api_protocol | https (default) / http | GLAB_API_PROTOCOL | | git_protocol | ssh (default) / https | GLAB_GIT_PROTOCOL | | editor | Editor | GLAB_EDITOR, VISUAL, EDITOR | | browser | Browser | GLAB_BROWSER, BROWSER | | glab_pager | Pager | GLAB_PAGER | | glamour_style | auto | dark | light | notty | GLAB_GLAMOUR_STYLE | | color | auto | never | always | GLAB_COLOR | | no_prompt | Disable interactive prompts | GLAB_NO_PROMPT | | check_update | Auto update check (default true) | GLAB_CHECK_UPDATE | | branch_prefix | Prefix for created branches | GLAB_BRANCH_PREFIX | | remote_alias | Remote name to use | GLAB_REMOTE_ALIAS | | skip_tls_verify | Skip TLS verification (per host) | GLAB_SKIP_TLS_VERIFY | | ca_cert | Custom CA (per host) | GLAB_CA_CERT | | client_cert / client_key | mTLS (per host) | GLAB_CLIENT_CERT / GLAB_CLIENT_KEY | | proxy | Proxy (per host) | GLAB_PROXY | | use_keyring | Use OS keyring (per host) | GLAB_USE_KEYRING | | telemetry | Send telemetry | GLAB_SEND_TELEMETRY | | debug | Debug logging | GLAB_DEBUG |

Self-managed / TLS

glab config set ca_cert /path/to/server.pem --host gitlab.example.com
glab config set skip_tls_verify true --host gitlab.example.com   # Dev only
glab config set client_cert /path/to/client.p12 --host gitlab.example.com
glab config set git_protocol ssh --host gitlab.example.com
GITLAB_HOST=gitlab.example.com glab repo clone group/project     # One-off host

Useful environment variables

| Variable | Purpose | |———-|———| | GITLAB_TOKEN | Token (overrides stored credential) | | GITLAB_HOST | Host (also GITLAB_URI, GL_HOST) | | GITLAB_REPO | Default repo for -R | | GITLAB_GROUP | Default group for -g (mr/issue/variable list, deploy-token…) | | GLAB_CONFIG_DIR | Config directory | | GLAB_NO_PROMPT | Non-interactive mode (also NO_PROMPT) | | GLAB_DEBUG / GLAB_DEBUG_HTTP | Debug logs / HTTP traces | | NO_COLOR | Disable color | | GLAB_ENABLE_CI_AUTOLOGIN | Auto-login with CI_JOB_TOKEN in GitLab CI |


Common Flags & Conventions

FlagDescription
-R, --repoTarget repo: OWNER/REPO, GROUP/NAMESPACE/REPO, full URL or Git URL
-g, --groupTarget group (on list/variable/token commands)
-p, --page / -P, --per-pagePagination (default per-page usually 30)
-F, --outputtext | json (on most view/list commands)
--jqFilter JSON output with a jq expression
-w, --webOpen in browser
-y, --yesSkip confirmation
  • MRs can be referenced by IID (123), source branch (feature, OWNER:feature) or URL.
  • Date filters accept YYYY-MM-DD, RFC 3339, or relative values (-7d, 2w, -1m, 1y).
  • @me refers to the authenticated user in assignee/reviewer filters.

Merge Requests (glab mr)

Create

glab mr create                                     # Interactive (alias: glab mr new)
glab mr create --fill --label bugfix               # Title/description from commits, push branch
glab mr create -f --draft --label RFC
glab mr create --fill --fill-commit-body --yes     # Non-interactive
glab mr create --fill --push=false --yes           # Don't push
glab mr create --fill --web                        # Continue in the browser
glab mr create -t "Fix login bug" --template bug_fix
glab mr create -t "Fix login bug" --description-file description.md
glab mr create -a alice --reviewer bob,carol -t "Add feature" -b main
glab mr create --source-branch feature --target-branch main \
  --title "Add feature" --description "Details..." --yes
glab mr create --repo upstream/project --head me/project \
  --source-branch feature --target-branch main --title "Add feature" --yes   # From fork
FlagDescription
-t, --title / -d, --descriptionTitle / description (-d - opens editor)
--description-fileDescription from file (- for stdin)
-f, --fillUse commit info; pushes the branch
--fill-commit-bodyInclude commit bodies in description
-s, --source-branch / -b, --target-branchBranches
-H, --headSource project OWNER/REPO (forks)
-a, --assignee / --reviewerUsernames
-l, --label / -m, --milestoneLabels / milestone
--draft (--wip)Mark as draft
--auto-mergeMerge when pipeline succeeds
--remove-source-branch / --squash-before-mergeMerge options
-i, --related-issue / --copy-issue-labelsLink an issue / copy its labels
--create-source-branchCreate source branch if missing
--allow-collaborationAllow commits from upstream members
--templateMR template name
--signoff / --no-editor / -y, --yesMisc

List

glab mr list                                       # Open MRs (alias: glab mr ls)
glab mr list --all                                 # All states
glab mr list --assignee=@me
glab mr list --reviewer=@me
glab mr list --author alice
glab mr list --label needs-review --not-label wip
glab mr list -M --per-page 10                      # Merged
glab mr list -c                                    # Closed
glab mr list --draft                               # Drafts only (--not-draft for the opposite)
glab mr list -t main -s feature                    # By target / source branch
glab mr list --search "login"
glab mr list -g my-group                           # Across a group
glab mr list --created-after=-1m --created-before=-1w
glab mr list -o updated_at -S desc
glab mr list -F json --jq '.[].web_url'

View / diff / checkout

glab mr view                                       # MR for current branch (alias: show)
glab mr view 123
glab mr view 123 --comments                        # With comments (--unresolved / --resolved)
glab mr view 123 -s                                # With system activity
glab mr view 123 --web
glab mr view 123 -F json --jq '{detailed_merge_status, has_conflicts}'
glab mr diff 123
glab mr diff 123 --raw                             # Raw diff (pipe to a pager or file)
glab mr diff 123 --color=never
glab mr checkout 123                               # Check out MR branch locally
glab mr checkout 123 --branch review-123
glab mr checkout new-feature --set-upstream-to=upstream/main
glab mr checkout 123 --worktree ../review-mr-123   # Into a git worktree
glab mr issues 123                                 # Issues closed by the MR
glab mr approvers 123                              # Approval rules/approvers

Update

glab mr update 23 --ready                          # Mark ready (-r)
glab mr update 23 --draft
glab mr update 23 -t "New title" -d "New description"
glab mr update 23 --label ui,ux --unlabel wip
glab mr update 23 --assignee +alice,-bob           # + add, - or ! remove
glab mr update 23 --reviewer +carol
glab mr update 23 --milestone ""                   # Unassign milestone
glab mr update 23 --target-branch develop
glab mr update 23 --fill --fill-commit-body --yes
glab mr update 23 --lock-discussion                # --unlock-discussion
glab mr update 23 --unassign
glab mr update feature-branch --state opened --ready

Review, approve, merge

glab mr approve 235                                # Approve (multiple IDs allowed)
glab mr approve 123 --sha abc123                   # Only if HEAD matches
glab mr revoke 235                                 # Revoke approval (alias: unapprove)
glab mr note 123 -m "LGTM"                         # Comment (alias: comment)
glab mr note list 123 --state unresolved           # List discussions (experimental)
glab mr note list --type diff --file src/main.go
glab mr note resolve 123 abc12345                  # Resolve a discussion (experimental)
glab mr rebase 123                                 # Rebase source branch on target
glab mr rebase 123 --skip-ci
glab mr merge 235                                  # Auto-merge when pipeline succeeds (default)
glab mr merge 235 --auto-merge=false               # Merge immediately
glab mr merge 235 --squash --remove-source-branch
glab mr merge 235 --rebase
glab mr merge 235 -m "Merge message" --squash-message "Squashed"
glab mr merge 235 --sha abc123 --yes
glab mr merge 235 --skip-ci

Lifecycle

glab mr close 1 2 3                                # Close one or more
glab mr reopen 123
glab mr delete 123
glab mr subscribe 123                              # / unsubscribe
glab mr todo 123                                   # Add a to-do item

Issues (glab issue)

Create

glab issue create                                  # Interactive (alias: new)
glab issue create -t "We need this" -m release-2.0.0 --label important
glab issue create -t "Security fix" -l security --confidential
glab issue create -t "Fix CVE" -l security --linked-mr 123
glab issue create -t "Bug report" --template bug   # From .gitlab/issue_templates/
glab issue create -t "Title" --description-file description.md
glab issue create -t "Title" -a alice --due-date 2026-12-31 -w 3 -e 2d
glab issue create -t "Title" --linked-issues 10,11 --link-type blocks
glab issue create -t "Title" --web
FlagDescription
-t, --title / -d, --descriptionTitle / description
--description-fileDescription from file (- for stdin)
-a, --assignee / -l, --label / -m, --milestoneMetadata
-c, --confidentialConfidential issue
--due-dateYYYY-MM-DD
-w, --weight / --epicWeight / epic ID
-e, --time-estimate / -s, --time-spentTime tracking
--linked-issues / --link-type / --linked-mrLinks (relates_to default)
--template / --no-editor / -y, --yes / --webMisc

List

glab issue list                                    # Open issues (alias: ls)
glab issue list --all                              # -A
glab issue list -c                                 # Closed
glab issue list --assignee=@me                     # @me, @none, @any
glab issue list --author alice --not-assignee bob
glab issue list --label bug --not-label wontfix
glab issue list --milestone release-2.0.0
glab issue list --search "login" --in title
glab issue list -t incident                        # issue | incident | test_case
glab issue list -C                                 # Confidential only
glab issue list -g my-group --epic 42
glab issue list --updated-after=-7d
glab issue list --order updated_at -s asc
glab issue list -F urls                            # details | ids | urls
glab issue list -O json --jq '.[].iid'             # Note: JSON output is -O here

View / update / comment / close

glab issue view 123                                # alias: show
glab issue view 123 --comments
glab issue view 123 --web
glab issue view https://gitlab.com/group/repo/-/issues/123
glab issue update 42 --label ui,ux --unlabel working
glab issue update 42 -t "New title" -d "New description"
glab issue update 42 --assignee +alice --milestone ""
glab issue update 42 --confidential                # --public to revert
glab issue update 42 --due-date 2026-12-31 -w 5
glab issue update 42 --estimate 2d --spend 1h30m   # Time tracking
glab issue update 42 --remove-estimate --remove-time-spent
glab issue update 42 --lock-discussion
glab issue note 123 -m "Looking into this now."    # alias: comment
glab issue note 123 -m "Internal info" --internal
glab issue note 123 < comment.md
glab issue close 123
glab issue reopen 123
glab issue delete 123
glab issue subscribe 123                           # / unsubscribe
glab issue board view                              # Issue boards (also: board create)

Incidents & work items

glab incident list
glab incident view 12                              # Also: close, reopen, note, subscribe, unsubscribe
glab work-items list                               # Experimental: create, update, delete

CI/CD Pipelines (glab ci)

Run & watch

glab ci run                                        # Run pipeline on current branch (alias: create)
glab ci run -b main
glab ci run --mr                                   # Merge request pipeline
glab ci run -b main --variables KEY1:val1 --variables KEY2:val2
glab ci run -b main --variables-env key1:val1,key2:val2
glab ci run -b main --variables-file MYKEY:file1
glab ci run -b main --variables-from variables.json   # [{"key":..,"value":..}]
glab ci run -b main --input "replicas:int(3)" --input "debug:bool(false)"
glab ci run --web
glab ci status                                     # Status of current branch pipeline
glab ci status --live                              # Live refresh
glab ci status --wait                              # Block until finished
glab ci status --compact
glab ci status -b main -F json
glab ci view                                       # Interactive TUI (Enter: logs, Ctrl+R: retry, Ctrl+D: cancel, Ctrl+Q: quit)
glab ci view -b main
glab ci view -p 12345                              # By pipeline ID (--pipelineid)
glab ci view --web

Jobs

glab ci trace                                      # Pick a job and stream its log
glab ci trace 224356863                            # By job ID
glab ci trace lint                                 # By job name
glab ci trace lint -b main -p 12345
glab ci retry                                      # Interactive
glab ci retry lint -p 12345
glab ci trigger deploy                             # Start a manual job
glab ci cancel pipeline 1504182795
glab ci cancel pipeline 1504182795,1504182796 --dry-run
glab ci cancel job 1504182795 --force              # --force for protected environments
glab job artifact main build                       # Download artifacts of job "build" on ref "main"
glab job artifact main deploy --path="artifacts/"
glab job artifact main deploy --list-paths
glab job artifact refs/merge-requests/123/head build

Inspect & list

glab ci list                                       # Recent pipelines
glab ci list --status=failed
glab ci list -r main --source merge_request_event
glab ci list --updated-after=-7d -u alice
glab ci list -F json --jq '.[].web_url'
glab ci get                                        # Pipeline JSON/details for current branch
glab ci get -p 12345 -d                            # With job details
glab ci get --merge-request=42 --status=failed --with-job-details
glab ci get --with-variables                       # Requires Maintainer

Lint & config

glab ci lint                                       # Validate ./.gitlab-ci.yml
glab ci lint path/to/.gitlab-ci.yml
glab ci lint --dry-run --ref main --include-jobs   # Simulate pipeline creation
glab ci config compile                             # Print fully expanded config
glab ci config compile --job test-job

Cleanup

glab ci delete 34                                  # Delete pipeline(s): 12,34,2
glab ci delete --status=failed
glab ci delete --older-than 24h --status=failed
glab ci delete --source=api --dry-run

Schedules (glab schedule, aliases sched, skd)

glab schedule list
glab schedule create --cron "0 0 * * *" --description "Nightly" --ref main
glab schedule create --cron "0 * * * *" --description "Hourly" --ref main \
  --cronTimeZone "Europe/Madrid" --variable "foo:bar" --variable "baz:qux"
glab schedule run 1                                # Run now
glab schedule update 1 ...                         # Also: delete

CI/CD Variables (glab variable, alias var)

glab variable list                                 # Project variables (alias: ls)
glab variable list -g my-group                     # Group variables
glab variable list -i                              # Instance variables
glab variable get VAR_KEY
glab variable get VAR_KEY -s production            # Specific environment scope
glab variable get VAR_KEY --inherited              # Include inherited group variables
glab variable set API_URL "https://api.example.com"
glab variable set TOKEN -v "secret" --masked --protected
glab variable set TOKEN --hidden -m                # Masked and hidden
glab variable set CERT --type file < cert.pem      # File-type variable
glab variable set DB_URL "..." --scope production -d "Prod DB"
glab variable set RAW_VAL '$NOT_EXPANDED' --raw
cat token.txt | glab variable set GROUP_TOKEN -g mygroup --scope=prod
glab variable update TOKEN -v "new-secret"
glab variable update TOKEN --protected=false
glab variable delete VAR_NAME                      # alias: remove
glab variable delete VAR_NAME -g mygroup --scope=prod
glab variable export                               # JSON (default)
glab variable export --output env                  # KEY=value
glab variable export --output export               # export KEY=value
glab variable export | glab variable import -R other/project      # Copy variables
glab variable import --input-file variables.json --skip-existing
set/update flagDescription
-v, --valueValue (or positional, or stdin)
-t, --typeenv_var (default) | file
-s, --scopeEnvironment scope (default *)
-m, --masked / --hiddenMask in logs / hide in UI (set only for hidden)
-p, --protectedOnly on protected branches/tags
-r, --rawDon’t expand variable references
-d, --descriptionDescription
-g, --groupGroup variable

Repositories (glab repo, alias project)

Clone

glab repo clone gitlab-org/cli
glab repo clone gitlab-org/cli mydir
glab repo clone https://gitlab.com/gitlab-org/cli
glab repo clone 4356677                            # By project ID
glab repo clone gitlab-org/cli -- --depth 1        # Pass git flags after --
glab repo clone gitlab-org/cli -- --branch development
glab repo clone --wiki gitlab-org/cli
glab repo clone -g my-group --paginate             # Clone every project in a group
glab repo clone -g my-group --preserve-namespace --paginate
glab repo clone -g my-group --archived=false --exclude-subgroup legacy --paginate
glab repo clone -g my-group -m -v private --paginate   # Only mine, private

Create / fork / delete

glab repo create                                   # From current directory
glab repo create my-project --private -d "Description" --readme
glab repo create my-group/my-project --public --defaultBranch main
glab repo create --group my-group -t topic1 -t topic2
glab repo create my-project --skipGitInit --remoteName gitlab
glab repo fork                                     # Fork current repo
glab repo fork namespace/repo --clone
glab repo fork namespace/repo -n new-name -p new-path --remote=false
glab repo delete mygroup/dotfiles                  # Permanent!
glab repo delete mygroup/dotfiles -y
glab repo transfer ...                             # Transfer to another namespace
glab repo update                                   # Update repo settings
glab repo view                                     # README + info for current repo
glab repo view group/repo -b develop
glab repo view --web
glab repo list                                     # Projects you own (alias: ls)
glab repo list -a                                  # All accessible
glab repo list --member --starred
glab repo list -g my-group -G --paginate           # Include subgroups
glab repo list -o star_count -s desc -F json
glab repo search -s "keyword"                      # aliases: find, lookup
glab repo contributors
glab repo archive group/repo --format=tar.gz -s v1.0.0   # Download source archive

Members, mirrors, remotes

glab repo members add --username=john.doe --role=developer
glab repo members add --username=jane --role=maintainer --expires-at=2026-12-31
glab repo members remove ...
glab repo mirror group/proj --direction=pull --url="https://gitlab.example.com/org/repo"
glab repo mirror group/proj --direction=push --url="https://backup.example.com/repo" --allow-divergence
glab repo mirror group/proj --direction=pull --url="..." --protected-branches-only
glab repo remote                                   # Manage git remotes
glab repo prune                                    # Prune local branches

Releases (glab release)

glab release list                                  # alias: ls
glab release list -F json
glab release view                                  # Latest release
glab release view v1.0.1 --web
glab release create v1.0.1                         # Creates tag from default branch if missing
glab release create v1.0.1 --notes "Bugfix release"
glab release create v1.0.1 -F CHANGELOG.md         # Notes from file (- for stdin)
glab release create v1.0.1 -n "Version 1.0.1" -r main -T "Tag message"
glab release create v1.0.1 -m v1.0 --no-close-milestone
glab release create v1.0.1 ./dist/*                # With assets
glab release create v1.0.1 '/path/asset.zip#Display label'
glab release create v1.0.1 '/path/asset.png#Display label#image'
glab release create v1.0.1 --released-at "2026-01-15T10:00:00Z"
glab release upload v1.0.1 ./dist/*.tar.gz         # Add assets to existing release
glab release upload v1.0.1 --assets-links='[{"name":"Docs","url":"https://example.com/docs","link_type":"other"}]'
glab release download v1.1.0                       # All assets
glab release download v1.1.0 -n "*.tar.gz" -D ./downloads
glab release download v1.1.0 --skip-existing       # Or --clobber to overwrite
glab release delete v1.0.1 -y                      # Requires Maintainer
glab release delete v1.0.1 --with-tag              # Also delete the git tag
release create flagDescription
-n, --nameRelease name
-N, --notes / -F, --notes-fileRelease notes (Markdown)
-r, --refCommit/branch for a new tag
-T, --tag-messageAnnotated tag message
-m, --milestone / --no-close-milestoneMilestones
-a, --assets-linksJSON array of asset links
-D, --released-atISO 8601 date
--no-updateFail instead of updating an existing release
--use-package-registry / --package-nameUpload assets to the generic package registry

Changelog

glab changelog generate                            # Uses the "Changelog" commit trailer
glab changelog generate --version 1.2.0
glab changelog generate --from abc123 --to def456
glab changelog generate --trailer Type --config-file .gitlab/changelog_config.yml

API (glab api)

glab api projects/:fullpath/releases               # Placeholders filled from current repo
glab api projects/gitlab-org%2Fcli/issues          # URL-encoded path
glab api user
glab api issues --paginate
glab api issues --paginate --output ndjson | jq 'select(.state == "opened")'
glab api projects/:fullpath/repository/branches/:target --placeholder target=feature/login
glab api -X POST projects/:id/issues -f title="Bug" -f description="Details"
glab api -X PUT projects/:id/merge_requests/1 -F squash=true   # -F = typed field
glab api -X POST projects/:fullpath/wikis/attachments --form "file=@./image.png" --form "branch=main"
echo '{"allowed_to_push":[{"user_id":1}]}' | glab api -X PATCH projects/:fullpath/protected_branches/main --input -
glab api -H "Accept: text/plain" -i projects/:id    # Custom header, include response headers
glab api --hostname gitlab.example.com version
glab api graphql -f query='query { currentUser { username } }'
FlagDescription
-X, --methodHTTP method (default GET; POST when fields are given)
-f, --raw-fieldString parameter key=value
-F, --fieldTyped parameter (true, numbers, @file)
--formMultipart form field (@file, @-)
--inputRequest body from file (- = stdin)
-H, --headerExtra header
-i, --includeInclude response status and headers
--paginateFetch all pages (GraphQL needs $endCursor + pageInfo)
--outputjson (default) | ndjson
--placeholderCustom :name placeholder name=value
--hostnameTarget host
--silentDon’t print the response body

Built-in placeholders: :branch, :fullpath, :group, :id, :namespace, :repo, :user, :username.


Labels, Milestones & Iterations

glab label list                                    # alias: ls
glab label list -g my-group -F json
glab label create --name bug --color "#FF0000" --description "Something is broken"
glab label create -n priority::high -p 1
glab label edit ...                                # Also: get, delete
glab milestone list
glab milestone create --title "Q4 release" --due-date 2026-12-16 --start-date 2026-10-01
glab milestone create --title "FY27" --due-date 2027-01-31 --group 456
glab milestone edit ...                            # Also: get, delete
glab iteration list --group my-group

Keys, Tokens & Access

# SSH / GPG keys for your user
glab ssh-key list
glab ssh-key add ~/.ssh/id_ed25519.pub -t "MacBook"
glab ssh-key add ~/.ssh/id_ed25519.pub -t "MacBook" -u auth --expires-at 2027-01-01
glab ssh-key get ...                               # Also: delete
glab gpg-key list                                  # Also: add, get, delete

# Deploy keys / deploy tokens
glab deploy-key list                               # Also: add, get, delete
glab deploy-token list -g my-group                 # Also: create, get, delete

# Access tokens (personal, project, group)
glab token list
glab token create my-project-token --access-level developer --scope read_repository --scope read_registry
glab token create my-group-token -g group/sub --access-level owner --scope api --duration 2w
glab token create my-pat --user @me --scope api --duration 90d
glab token create ci-token -A maintainer -S api --expires-at 2026-12-31
glab token rotate my-project-token                 # Also: revoke

# Service accounts
glab service-account list -g my-group              # Also: create, get, update, delete, token

Snippets, Packages & Registries

# Snippets
glab snippet create script.py --title "My script"
glab snippet create -t "Title" -d "Description" -f renamed.go main.go
echo "package main" | glab snippet create --title "Snippet" --filename main.go
glab snippet create --personal -t "Personal" -v public script.py

# Generic packages
glab packages list
glab packages upload ./build/app.zip --name my-package --version 1.0.0
glab packages upload ./build/app.zip -n my-package -v 1.0.0 --filename release.zip
glab packages download --name my-package --version 1.0.0 --filename app.zip --path ./downloads/
glab packages delete ...

# Container registry (alias: cr)
glab container-registry repository list
glab container-registry tag list 123
glab container-registry tag delete 123 latest

# Secure files (CI)
glab securefile list                               # Also: create, download, get, remove, update

Runners, Clusters & Infrastructure

glab runner list                                   # Also: assign, unassign, update, delete, jobs, managers
glab cluster agent list                            # Kubernetes agents
glab cluster graph
glab opentofu init ...                             # GitLab-managed OpenTofu/Terraform state (aliases: tf, terraform)
glab opentofu state ...

Stacked Diffs (glab stack, experimental)

glab stack create cool-new-feature                 # Start a stack (alias: new)
glab stack save -m "Add a function"                # Commit as a new stacked diff
glab stack save -a -m "Change existing file"       # Stage all
glab stack amend                                   # Amend current diff
glab stack sync                                    # Push and create/update MRs
glab stack sync --reviewer alice --label bug --update-base
glab stack sync --skip-mr-creation                 # Push only
glab stack list
glab stack next | glab stack prev | glab stack first | glab stack last
glab stack switch <stack-name>
glab stack reorder | glab stack move | glab stack delete

Aliases

glab alias set mrv 'mr view'                       # glab mrv -w 123
glab alias set createissue 'issue create --title "$1"'
glab alias set --shell igrep 'glab issue list --assignee="$1" | grep $2'
glab alias list
glab alias delete mrv

Misc

glab todo list                                     # Your to-do items
glab todo done 123
glab todo done --all
glab timelog list                                  # Time tracking entries
glab user events                                   # Your activity
glab search semantic ...                           # Beta
glab duo cli                                       # GitLab Duo CLI (GitLab 19.2+)
glab duo cli --install

GitLab CI Usage

release:
  image: registry.gitlab.com/gitlab-org/cli:latest
  variables:
    GLAB_ENABLE_CI_AUTOLOGIN: "true"     # Logs in with CI_JOB_TOKEN automatically
  script:
    - glab release create "$CI_COMMIT_TAG" --notes "See CHANGELOG.md" --ref "$CI_COMMIT_SHA"
  rules:
    - if: $CI_COMMIT_TAG

Manual login alternative:

glab auth login --job-token $CI_JOB_TOKEN --hostname $CI_SERVER_FQDN --api-protocol $CI_SERVER_PROTOCOL
GITLAB_HOST=$CI_SERVER_FQDN glab release list -R $CI_PROJECT_PATH

Never set GITLAB_TOKEN=$CI_JOB_TOKEN; it fails with 401/404. For endpoints the job token can’t reach, use a project/group access token with api scope in GITLAB_TOKEN.


Scripting Recipes

# Non-interactive mode
export GLAB_NO_PROMPT=true

# Open MR for current branch and wait for its pipeline
glab mr create --fill --yes && glab ci status --wait

# URLs of my open MRs awaiting review
glab mr list --reviewer=@me -F json --jq '.[].web_url'

# Check if an MR is mergeable
glab mr view 123 -F json --jq '{detailed_merge_status, has_conflicts}'

# Failed jobs of an MR's head pipeline
glab ci get --merge-request=42 --status=failed --with-job-details

# Copy CI variables between projects
glab variable export -R group/src | glab variable import -R group/dst --skip-existing

# Clone a whole group, preserving the directory structure
glab repo clone -g my-group --preserve-namespace --paginate

# Debug HTTP calls
GLAB_DEBUG_HTTP=1 glab api user