| | |

GitLab 25 🦊 Cheat Sheet

⏱️ Estimated read: 3 min | |

1. Repositories & SSH/HTTPS Authentication

git clone git@gitlab.com:group/project.git       # Clone via SSH
git clone https://gitlab.com/group/project.git   # Clone via HTTPS
ssh-keygen -t ed25519 -C "email@example.com"     # Generate SSH key
ssh -T git@gitlab.com                            # Test SSH connection
# PAT (Personal Access Token) clone
git clone https://<username>:<token>@gitlab.com/group/project.git

2. Project & Group Hierarchy

LevelPurposeContains
GroupOrganizationSubgroups, projects
SubgroupTeamSubgroups, projects
ProjectRepositoryCode, issues, MRs, CI/CD
Create group: Menu → Groups → New group
Create project: Menu → Projects → New project
Max nesting: 20 levels

3. Merge Requests (MRs)

glab mr create --fill --reviewer username        # Create MR via CLI
glab mr list                                     # List MRs
glab mr checkout 42                              # Checkout MR branch
glab mr merge 42 --squash --remove-source-branch # Merge MR via CLI
# Resolve conflicts locally
git fetch origin
git merge origin/main
# Edit conflicted files, then:
git add <file> && git commit && git push

4. Protected Branches

Settings → Repository → Protected branches
Branch: main
Allowed to merge: Maintainers
Allowed to push: Maintainers
Allowed to force push: Disabled
RoleCan Push to main? (Default)
GuestNo
ReporterNo
DeveloperNo (protected)
MaintainerYes
OwnerYes

5. .gitlab-ci.yml Basic Structure

stages:
  - build
  - test
  - deploy

build-job:
  stage: build
  script:
    - npm ci
    - npm run build
  artifacts:
    paths:
      - dist/

test-job:
  stage: test
  needs: [build-job]
  script:
    - npm test

6. CI/CD Pipeline Keywords

KeywordPurpose
stagesDefines execution order
scriptCommands to run
imageContainer environment
needsBypass stage barrier (DAG)
rulesConditional execution
artifactsPass files between jobs
cacheReuse dependencies
environmentDeployment target

7. rules and Conditional Execution

deploy:
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
      when: manual
    - if: $CI_COMMIT_TAG
    - when: never
when ValueMeaning
on_successRun if previous jobs pass
on_failureRun only on failure
alwaysAlways run
neverNever run
manualRequire manual trigger
delayedDelay start

8. CI/CD Variables

Settings → CI/CD → Variables → Add variable
Key: DEPLOY_TOKEN
Value: <secret>
Masked: Yes
Protected: Yes
Environment scope: production
VariablePurpose
CI_COMMIT_SHACommit hash
CI_COMMIT_BRANCHBranch name
CI_PIPELINE_IDPipeline ID
CI_REGISTRY_IMAGEContainer registry path
CI_JOB_TOKENShort-lived job token

9. Runners

sudo gitlab-runner register --token "glrt-xxxx" --executor "docker"
sudo systemctl restart gitlab-runner
ExecutorUse Case
dockerContainer isolation
shellDirect host execution
kubernetesPod-based scaling

10. Container Registry (GHCR Equivalent)

before_script:
  - echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
script:
  - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA .
  - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA

11. DevSecOps Scanners

include:
  - template: Security/SAST.gitlab-ci.yml
  - template: Security/Secret-Detection.gitlab-ci.yml
  - template: Jobs/Dependency-Scanning.gitlab-ci.yml
ScannerTemplate
SASTSecurity/SAST.gitlab-ci.yml
Secret DetectionSecurity/Secret-Detection.gitlab-ci.yml
Dependency ScanningJobs/Dependency-Scanning.gitlab-ci.yml

12. Environments and Deployments

deploy-staging:
  environment:
    name: staging
    url: https://staging.example.com
  script: ./deploy.sh

deploy-prod:
  environment:
    name: production
  when: manual
  allow_failure: false
  script: ./deploy.sh
Settings → CI/CD → Protected environments
Environment: production
Allowed to deploy: Maintainers
Required approvals: 1

13. Kubernetes Agent

helm upgrade --install my-agent gitlab/gitlab-agent \
  --namespace gitlab-agent \
  --set config.token=<token> \
  --set config.kasAddress=wss://kas.gitlab.com
# .gitlab/agents/my-agent/config.yaml
gitops:
  manifest_projects:
    - id: my-group/manifests

14. Access Control

RoleKey Permissions
GuestView issues, comment
ReporterView code, clone
DeveloperPush, create MRs
MaintainerManage settings, protect branches
OwnerDelete project, transfer
VisibilityVisible To
PrivateMembers only
InternalAuthenticated users
PublicAnyone

15. Webhooks & API

curl --header "PRIVATE-TOKEN: <token>" \
  "https://gitlab.example.com/api/v4/projects"
HeaderToken Type
PRIVATE-TOKENPersonal access token
JOB-TOKENCI/CD job token
Authorization: BearerOAuth

16. Analytics

MetricDefinition
Lead TimeIssue creation to closure
Cycle TimeFirst commit to issue closure
DORA: Deployment FrequencyDeployments per day
DORA: Change Failure RateFailed deployments %

17. Migration

SourceTool
GitHubCreate new → Import project → GitHub
Bitbucket CloudCreate new → Import project → Bitbucket Cloud
Git History onlyRepository by URL

Was this helpful?


Stop using slow, ad-bloated tool sites! 🤮

🔎 Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)

⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free

🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!