GitLab User Manual
Account Management
Registration and Login
To use GitLab for the first time, click "Register" on the login page to create an account. Registration requires providing a username, email address, and password. Username choice should be careful, as it cannot be changed after creation. After registration, you'll receive a verification email. Click the link in the email to complete email verification.
After logging in, you can improve your profile in personal settings, including avatar, name, full name, and bio. It's recommended to fill in complete information, as this will be displayed in project member lists and commit records. You can also bind SSH keys for pushing code via command line.
SSH Key Configuration
SSH keys allow secure authentication with GitLab repositories without entering username and password each time. First, generate an SSH key pair:
ssh-keygen -t ed25519 -C "[email protected]"
The generated public key is located in ~/.ssh/id_ed25519.pub. Log in to GitLab, go to user settings, click the "SSH Keys" tab, paste the public key content into the text box, and save. After adding the key, you can clone repositories using SSH:
git clone [email protected]:username/project.git
Project Operations
Creating a Project
After logging in, click the "New Project" button in the top navigation bar to create a new project. You can choose to create a blank project, create from a template, or import an existing project. When creating, you need to set the project name, description, visibility level (Public, Internal, Private), and default branch name.
Project names should be concise and clear, using English and hyphens for naming. Private projects are only accessible to project members. Internal projects are visible to all logged-in users within the enterprise. Public projects are visible to everyone. After creation, you can modify these options in the project settings page.
Branch Management
GitLab uses main as the default main branch (earlier versions used master). Click "Branches" on the project page to view and manage all branches. Create a new branch by: clicking "New Branch" on the branches page, or using Git commands:
git checkout -b feature/new-feature
Protected branches are an important feature for team collaboration. Go to Project Settings → Repository → Protected Branches to set which users can push or merge to specific branches. It's recommended to protect the main branch, allowing only specific roles or maintainers to merge code.
Merge Requests
Merge Requests are the core feature for code collaboration in GitLab. After completing feature development and pushing the branch, click "Merge Requests" → "New Merge Request" on the project page. Select the source branch and target branch, fill in the title and description, then create.
The Merge Request page shows the differences between the source and target branches, including file changes and commit history. Team members can perform code review here, adding line-by-line comments. After review is complete, if merge conditions are met (such as passing CI tests and receiving approvals), the branch can be merged.
CI/CD Pipelines
.gitlab-ci.yml Configuration
GitLab CI/CD uses the .gitlab-ci.yml file in the project root to define pipelines. This is a YAML configuration file describing each build stage and job. Here's a simple example:
stages:
- build
- test
- deploy
build:
stage: build
script:
- npm install
- npm run build
artifacts:
paths:
- dist/
test:
stage: test
script:
- npm run test
coverage: '/Coverage: \d+\.\d+%/'
deploy:
stage: deploy
script:
- ./deploy.sh
only:
- main
This configuration defines three stages: build for building the project, test for running tests, and deploy for deploying the application. Artifacts are used to pass build artifacts between jobs, and only specifies to run deploy jobs only on the main branch.
GitLab Runner
GitLab Runner is the agent that executes CI/CD jobs. GitLab provides shared Runners, or you can register your own private Runners. Install GitLab Runner on your server:
# Install
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt-get install gitlab-runner
# Register Runner
sudo gitlab-runner register
Registration requires providing the GitLab instance URL and registration token, which can be found in Project Settings → CI/CD → Runners. Runners can be configured to execute jobs in parallel to improve build speed.
Pipeline Monitoring
After each code push, the pipeline automatically triggers. You can view all pipeline run statuses on the Project → CI/CD → Pipelines page. Click on a specific pipeline to see each job's execution status, including log output, build time, and failure reasons.
GitLab also provides a Pipeline Editor that creates and edits CI/CD configurations visually, eliminating the need to manually write YAML files. The editor provides syntax checking and real-time preview, reducing configuration errors.
Issue Tracking
Creating and Managing Issues
The issue system is the foundation of GitLab project management. On the project page, click "Issues" → "New Issue" to create a new issue. You need to fill in the title and description, and can choose to assign to specific members, set labels, milestones, and due dates.
Issue status is managed through labels or milestones. Common labels include bug, feature, enhancement, etc. You can use the board view to visualize issue status, grouping issues by columns (e.g., To Do, In Progress, Done).
Linking Issues to Code
Using keywords plus issue numbers in commit messages or Merge Request descriptions automatically links code to issues. For example:
- Fixes #123 - Fixes issue 123, will automatically close the issue after merging
- Closes #456 - Closes issue 456
- See #789 - References issue 789
This linking mechanism helps teams track work progress and understand issue background and purpose during code review.
Wikis and Documentation
Each GitLab project includes built-in wiki functionality for creating project documentation. Wiki pages are written in Markdown format, supporting syntax highlighting, tables, and images. Wiki content supports version control just like code repositories, allowing you to view historical versions and rollback.
It is recommended to maintain the following documentation for projects: README for project introduction, CONTRIBUTING for contribution guidelines, deployment guides, and API documentation. These documents can significantly reduce onboarding difficulty and promote community contributions.
