Complete command reference and workflow guide for GitLab CLI (glab).
Quick Start
# 首次配置
glab auth login
# 常用操作
glab mr create --fill # 从当前分支创建合并请求
glab issue create # 创建 Issue
glab ci view # 查看流水线状态
glab repo view --web # 在浏览器中打开仓库
Skill Organization Structure
This skill routes to specialized sub-skills by GitLab functional domain:
Core Workflows:
glab-mr- Merge Requests: create, review, approve, mergeglab-issue- Issues: create, list, update, close, commentglab-ci- CI/CD: pipelines, jobs, logs, artifactsglab-repo- Repositories: clone, create, fork, manage
Project Management:
glab-milestone- Release planning and milestone trackingglab-iteration- Sprint/iteration managementglab-label- Label management and categorizationglab-release- Software releases and version management
Authentication and Configuration:
glab-auth- Login, logout, Docker Registry authenticationglab-config- CLI configuration and default settingsglab-ssh-key- SSH key managementglab-gpg-key- GPG keys (for commit signing)glab-token- Personal and project access tokens
CI/CD Management:
glab-job- Individual job operationsglab-schedule- Scheduled pipelines and Cron jobsglab-variable- CI/CD variables and secretsglab-securefile- Pipeline secure filesglab-runner- Runner management: list, pause, delete (new in v1.87.0)glab-runner-controller- Runner controllers and token management (experimental, administrators only)
Collaboration:
glab-user- User profiles and informationglab-snippet- Snippets (similar to GitLab Gist)glab-incident- Incident managementglab-workitems- Work items: tasks, OKRs, key results, next-generation Epics (new in v1.87.0)
Advanced:
glab-api- Direct REST API callsglab-cluster- Kubernetes cluster integrationglab-deploy-key- Deploy keys (for automation)glab-stack- Stacked/dependent merge requestsglab-opentofu- Terraform/OpenTofu state management
Tools:
glab-alias- Custom command aliasesglab-completion- Shell autocompletionglab-help- Command help and documentationglab-version- Version informationglab-check-update- Update checksglab-changelog- Changelog generationglab-attestation- Software supply chain securityglab-duo- GitLab Duo AI assistantglab-mcp- Model Context Protocol server for AI assistant integration (experimental)
When to Use glab vs. the Web Interface
Scenarios suitable for using glab:
- Automating GitLab operations in scripts
- Terminal-centric workflows
- Batch operations (processing multiple MRs/Issues)
- Integration with other CLI tools
- CI/CD pipeline workflows
- Quick navigation without switching to a browser
Scenarios suitable for using the Web interface:
- Complex diff review with inline comments
- Visual merge conflict resolution
- Configuring repository settings and permissions
- Advanced search/filtering across projects
- View security scan results
- Manage group/instance-level settings
Common workflows
Daily development
# 开始处理某个 Issue
glab issue view 123
git checkout -b 123-feature-name
# 准备好后创建 MR
glab mr create --fill --draft
# 标记为可审查
glab mr update --ready
# 审批通过后合并
glab mr merge --when-pipeline-succeeds --remove-source-branch
Code review
# 查看待审查列表
glab mr list --reviewer=@me --state=opened
# 审查某个 MR
glab mr checkout 456
glab mr diff
npm test
# 批准
glab mr approve 456
glab mr note 456 -m "LGTM! Nice work on the error handling."
CI/CD debugging
# 检查流水线状态
glab ci status
# 查看失败的任务
glab ci view
# 获取任务日志
glab ci trace <job-id>
# 重试失败的任务
glab ci retry <job-id>
Decision tree
"Should I create an MR first or an Issue first?"
需要跟踪工作进度?
├─ 是 → 先创建 Issue(glab issue create)
│ 然后:glab mr for <issue-id>
└─ 否 → 直接创建 MR(glab mr create --fill)
Scenarios for using glab issue create + glab mr for :
- Discussion/approval needed before coding
- Tracking feature requests or bugs
- Sprint planning and assignment
- Want the Issue to close automatically when the MR is merged
Scenarios for using glab mr create directly:
- Quick fixes or typos
- An existing Issue is already being handled
- Urgent fixes or hotfixes
"Which CI command should I use?"
你需要什么?
├─ 查看流水线整体状态 → glab ci status
├─ 可视化流水线视图 → glab ci view
├─ 查看特定任务日志 → glab ci trace <job-id>
├─ 下载构建产物 → glab ci artifact <ref> <job-name>
├─ 验证配置文件 → glab ci lint
├─ 触发新运行 → glab ci run
└─ 列出所有流水线 → glab ci list
Quick reference:
- Pipeline level:
glab ci status、glab ci view、glab ci run - Job level:
glab ci trace、glab job retry、glab job view - Artifacts:
glab ci artifact(by pipeline) or get job artifacts viaglab jobGet task artifacts
"Clone or Fork?"
你与仓库的关系?
├─ 有写入权限 → glab repo clone group/project
├─ 向他人项目贡献代码:
│ ├─ 一次性贡献 → glab repo fork + 工作 + MR
│ └─ 持续贡献 → glab repo fork,然后定期同步
└─ 仅阅读/浏览 → glab repo clone(或 view --web)
Scenarios suited for Fork:
- No write access to the original repository
- Contributing code to open source projects
- Experimenting without affecting the original repository
- Need your own copy for long-term work
Scenarios suited for Clone:
- You are a project member with write access
- Working on an organization/team repository
- No personal copy needed
"Project labels or group labels?"
标签应该放在哪?
├─ 跨多个项目使用 → glab label create --group <group>
└─ 仅限某个项目 → glab label create(在项目目录中)
Group-level labels:
- Unified label system across the organization
- Examples: priority::high, type::bug, status::blocked
- Centrally managed, automatically inherited by projects
Project-level labels:
- Project-specific workflows
- Examples: needs-ux-review, deploy-to-staging
- Managed by project maintainers
Related skills
MR and Issue workflows:
- Start creating/tracking work from
glab-issueStart creating/tracking work - Use
glab-mrto create an MR that closes an Issue - Script:
scripts/create-mr-from-issue.shautomates this process
CI/CD debugging:
- Use
glab-cifor pipeline-level operations - Use
glab-jobfor single job operations - Script:
scripts/ci-debug.shquickly diagnoses failure causes
Repository operations:
- Use
glab-repofor repository management - Use
glab-authfor authentication configuration - Script:
scripts/sync-fork.shsyncs forks
Configuration:
- Use
glab-authfor initial authentication - Use
glab-configto set defaults and preferences - Use
glab-aliasto create custom shortcuts