Complete Guide to GitLab Setup and Usage: Groups, Users, Projects, and Permissions

Installing and Using GitLab

To initiate a new repository, choose 'Create a new repository' to start with an empty one, then proceed to develop and commit code.

Alternatively, use 'Push an existing folder' when you already have source code ready to upload.

Cloning and Committing Files

After cloning the repository, create files within it and commit them to the repository.

Creating a Branch

Mainline vs Feature Development

In mainline development, all changes are made directly on the main branch (typically main or master).

In feature branching, new features are developed in separate branches derived from the main branch. Once completed, these branches undergo pipeline validation before merging into the main branch for release.

Feature branching workflow includes:

  1. Create a release branch from main (e.g., release-1.1.1).
  2. Create feature branches from main (e.g., feature-1, feature-2).
  3. After feature completion, merge the feature branch into the release branch.
  4. Deploy from the release branch acros environments (dev, staging, production).
  5. Finally, tag the main branch up on successful deployment.

Fetching Feature Branches

Why fetch branches? To isolate feature development from the main branch, preventing accidental pollution of production-ready code.

Navigate to the project homepage and create a feature branch named feature-1-DEV based on main.

Developing and Committing Feature Branch Changes

Merging Feature Branches

Merge the feature branch feature-1-DEV into main via a Merge Request.

On the merge request page:

  1. Set a descriptive title.
  2. Add a detailed description of changes.
  3. Assign a reviewer for approval.
  4. Assign peers for code review.
  5. Optional delete the source branch post-merge (recommended for cleanup).

Once reviewed and approved by an administrator, the merge can proceed.

This completes a standard GitLab development cycle.

Transferring Projects to Subgroups

In GitLab, projects can be transferred to subgroups under Settings > General > Transfer Project. This action requires admin rights for the target group.

Permissions Overview:

  • Guest: Can comment and view issues, cannot read/write repositories.
  • Reporter: Clone code, cannot commit.
  • Developer: Clone, develop, commit, and push code.
  • Maintainer: Manage project settings, protect branches, manage members.
  • Owner: Full control including visibility, deletion, and migration of projects.

Only Owners can transfer projects between groups.

Managing Git Submodules

A Git submodule allows embedding another Git repository as a subdirectory within a parent repository.

Submodule entries are stored in .gitmodules:

[submodule "module_name"]
  path = file_path
  url = repo_url

Adding a Submodule

  1. Initialize a new project.
  2. Clone it locally:
    git clone https://github.com/xugaoxiang/gitDemo.git
    
  3. Add a submodule:
    git submodule add https://github.com/ultralytics/yolov5.git
    

The directory now includes a .gitmodules file listing submodule configurations.

Viewing Submodules

Check added submodules using:

git submodule

Committing Submodules

Add and commit the submodule:

git add .gitmodules
 git commit -m "add drpo gitmodules"
 git push origin main

Cloning Repositories with Submodules

When cloning, initialize and update submodules:

# Method 1
 git submodule init
 git submodule update

# Method 2 (preferred)
 git clone https://github.com/xugaoxiang/gitDemo.git --recursive

Updating Submodules

To synchronize with remote updates:

 git submodule update --remote

Removing Submodules

To remove a submodule:

  1. Remove the submodule entry:

    git rm yolov5
    
  2. Edit .gitmodules to remove related lines.

  3. Update .git/config accordingly.

  4. Delete submodule directory from .git/modules/.

Tags: gitlab Git Version Control project management submodule

Posted on Thu, 25 Jun 2026 17:08:41 +0000 by morphboy23