| name | using-glab |
| description | Reference for using the glab CLI to interact with GitLab CI/CD pipelines and merge requests. Use when checking pipeline status, viewing job logs, creating or reviewing MRs, approving, commenting, or merging. |
Using glab CLI
Run glab commands via the Bash tool. Omit the MR <id> to target the MR for the current branch.
Merge Requests
Reading MR state
glab mr list
glab mr list --draft
glab mr list --reviewer=@me
glab mr list --label=bug --target-branch=main
glab mr view 123
glab mr view 123 --comments
glab mr view 123 --output json
glab mr diff 123
glab mr approvers 123
glab mr issues 123
Creating and updating MRs
glab mr create --title "Add feature" \
--description "Details here" \
--assignee user1 \
--reviewer user2 \
--label feature \
--target-branch main \
--draft \
--remove-source-branch \
--squash-before-merge
glab mr for 42 --target-branch main --with-labels
glab mr update 123 --title "New title"
glab mr update 123 --reviewer user1,user2
glab mr update 123 --label add-label --unlabel remove-label
glab mr update 123 --ready
Review workflow
glab mr approve 123
glab mr approve 123 --sha <commit-sha>
glab mr revoke 123
glab mr note 123 --message "Looks good"
glab mr checkout 123
glab mr checkout 123 --branch my-local-branch
For inline diff comments on specific lines, use the API:
glab mr view 123 --output json | jq '.diff_refs'
glab api projects/:id/merge_requests/123/discussions \
-X POST \
-f "body=Comment text" \
-f "position[base_sha]=<base>" \
-f "position[head_sha]=<head>" \
-f "position[start_sha]=<start>" \
-f "position[position_type]=text" \
-f "position[new_path]=path/to/file.py" \
-f "position[new_line]=42"
Merging and lifecycle
glab mr merge 123
glab mr merge 123 --squash
glab mr merge 123 --squash --squash-message "feat: message"
glab mr merge 123 --auto-merge
glab mr merge 123 --rebase --remove-source-branch
glab mr rebase 123
glab mr close 123
glab mr reopen 123
CI/CD Pipelines
Checking pipeline status
glab ci status
glab ci status --branch feature-x
glab ci list
glab ci list --status failed
glab ci list --output json
glab ci get
glab ci get --branch main --with-job-details
glab ci get --pipeline-id 456 --with-variables
Running and managing pipelines
glab ci run
glab ci run --branch main
glab ci run --variables KEY1=val1
glab ci trigger <job-name>
glab ci retry <job-name>
glab ci cancel job <job-name>
glab ci cancel pipeline
Debugging failures
glab ci trace <job-name>
glab ci trace <job-name> --pipeline-id 456
glab ci artifact <job-name>
glab ci artifact <job-name> --path ./output
CI config validation
glab ci lint
glab ci lint --include-jobs
glab ci config compile
Common Workflows
Investigate a failing pipeline
glab ci status — identify which pipeline is failing
glab ci get --with-job-details — find the failed job name
glab ci trace <job-name> — read the failure logs
- Fix the code, push, then
glab ci status to verify
Review and approve an MR
glab mr view 123 --comments — read description, metadata, and discussion
glab mr diff 123 — review the code changes
glab mr note 123 --message "feedback" — leave feedback
glab mr approve 123 — approve when satisfied
Create MR with pipeline check
glab mr create --title "..." --description "..." --draft — create as draft
glab ci status — monitor pipeline
glab mr update --ready — mark ready for review when CI passes
API Fallback
Use glab api for operations without a dedicated subcommand:
glab api <endpoint>
glab api <endpoint> -X POST -f key=value
glab api <endpoint> --paginate