GitLab Cheat Sheet

Projects, merge requests, pipelines, CI/CD variables, and the GitLab API — self-hosted or SaaS, these are the commands.

Core DevOps7 sections · 47 commands
⌘K

glab CLI & Auth

5
glab auth login

Authenticate glab (GitHub, GitLab, or custom)

glab auth status

Show auth state

glab auth logout

End the session

glab config set --global gitlab_uri https://gitlab.example.com

Point at a self-hosted instance

glab version

glab version

Projects & Repos

6
glab repo clone OWNER/REPO

Clone a project

glab repo view OWNER/REPO

View project details

glab repo create NAME --public

Create a project

glab repo create --fork OWNER/REPO

Fork a project

glab repo list --owner

List visible projects

git push --set-upstream origin HEAD

Push current branch as MR source

Merge Requests

10
glab mr create

Create an MR from the current branch

glab mr create --draft

Draft MR

glab mr list

Open MRs in the repo

glab mr list --all --label review:needed

Filter MRs by label

glab mr view MR_ID

View an MR

glab mr checkout MR_ID

Check out the MR branch

glab mr diff MR_ID

Show the MR diff

glab mr approve MR_ID

Approve an MR

glab mr merge MR_ID --squash

Squash-merge an MR

glab mr close MR_ID

Close without merging

Issues

6
glab issue create --title "T" --description "D"

Create an issue

glab issue list

List open issues

glab issue list --assignee USER --label bug

Filter by assignee/label

glab issue view ISSUE_ID

View an issue

glab issue close ISSUE_ID

Close an issue

glab issue board

Show the issue board

CI/CD Pipelines

9
glab ci view

Latest pipeline status

glab ci view PIPELINE_ID

View a specific pipeline

glab ci status

Show pipeline/job status

glab ci list

Recent pipelines

glab ci run --ref main

Trigger a pipeline for a ref

glab ci create

Run a new pipeline

glab ci trace JOB_ID

Stream a job's log

glab ci retry JOB_ID

Re-run a failed job

glab ci delete PIPELINE_ID

Delete a pipeline

REST API

7
glab api /projects?search=NAME

Search projects

glab api /projects/:id/pipelines

Pipelines for a project

glab api /projects/:id/variables

List CI/CD variables

glab api -X POST /projects/:id/variables -f key=NAME -f value=VALUE

Add a CI/CD variable

glab api /projects/:id/merge_requests?state=opened

Open MRs via API

glab api /projects/:id/releases

Releases via API

glab api /version

Server version

Variables & Secrets

4
glab variable list

Project CI/CD variables

glab variable set NAME

Create/update a variable

glab variable set NAME --value VAL --masked

Set as masked

glab variable delete NAME

Delete a variable