Introduction to Gitlab

Urs Roesch

What is GitLab

GitLab is a complete DevOps platform, delivered as a single application. This makes GitLab unique and creates a streamlined software workflow, unlocking your organization from the constraints of a pieced together toolchain. Learn how GitLab offers unmatched visibility and higher levels of efficiency in a single application across the DevOps lifecycle.

Gitlab project

Create a new project

In the following steps a new personal public repository is created. The process of creating a new project is assisted and straight forward.

The creation starts with clicking on the boxed plus sign left to the search field.

project new project
Figure 1. Create a new project from the top navigation bar
project new project options
Figure 2. Choose project’s starting point
project new project create
Figure 3. Fill in the required information

Navigate new project

Right after the project is created the next screen is the project overview. For a first time visitor the screen has quite a few elements and is probably confusing at first sight.

Here the various elements are explained shortly to provide and initial overview where to find which functionality.

project new project initial
Figure 4. Initial project overview screen.

Clone project

GitLab has quite a few tools allowing for changes to the git repository data via the web interface. But for most purposes the content of the git repository is worked on with an IDE or on the command line externally.

In this exercise the previously created gitlab-project is cloned from the command line.

project clone
Figure 5. Copy project address for git clone operation.

Change to terminal window and execute

$ git clone ssh://git@gitlab.local:8422/jdev/gitlab-project.git (1)
Cloning into 'gitlab-project'...
X11 forwarding request failed on channel 0
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
$ cd gitlab-project (2)
$ git log (3)
commit 3651309571108055dcafb3dacaf9678e90c91291 (HEAD -> main, origin/main, origin/HEAD) (4)
Author: Joe Developer <joe.developer@gitlab.local>
Date:   Mon Nov 9 12:10:30 2020 +0000

    Initial commit

Navigate plan

Besides the managing repositories Gitlab also sports tools to plan like manage issues and kanban boards among others for the project.

project plan issues
Figure 6. Issue List view
project plan issue boards
Figure 7. Issue Boards view
project issues new issue
Figure 8. Create new issue

Navigate code

There are a few tools to get a better insight of what is happening with the code both in and around the repository.

project code merge requests
Figure 9. Merge requests overview
project code repository
Figure 10. Repository view
project code branches
Figure 11. Branches view
project code commits
Figure 12. Repository Commits view
project code tags
Figure 13. Tags view
project code repository graph
Figure 14. Repository graph view
project code compare
Figure 15. Compare view

Repository protection

Among the many settings available for a GitLab project at this stage the one that really matters is the protection of the main branch.

Per default only the maintainer can push and as such also force push changes to the main branch. This can be further restricted and no one make changes to main without proper evaluation of the changes.

project new project repository protection
Figure 16. Restrictive main branch settings.
By protecting the main branch from direct pushes one can prevent fat-fingered git pushes where main gets accidentally overwritten with content from another branch. As a disclaimer this never happened to the instructor guiding you currently, ever!!!

Gitlab group

Create a new group

In the following steps a new group is created. The process of creating a new group is assisted and straight forward.

The creation starts with clicking on the boxed plus sign left to the search field.

group new group
Figure 17. Create a new group from the top navigation bar
group new group options
Figure 18. Choose create options
group new group create
Figure 19. Fill in the required information
group overview
Figure 20. Initial group overview

Group members

An integral part of groups is membership management.

The task is very straight forward but has a couple of Gitlab specific settings which need further explanation.

group members
Figure 21. Manage group members
group members invite
Figure 22. Manage group members

Merge requests

Goals

  • Create a merge request from a feature branch.

  • Submit a merge request.

  • Review changes in a merge request.

  • Amend a merge request.

  • Merge the request.

Create merge request

Initiate merge request

merge request create 01
Figure 23. After pushing a branch notification appears on the overview page.
merge request create 02
Figure 24. Create merge request via CodeRepository
merge request create 03
Figure 25. Create merge request via CodeBranches
merge request create 04
Figure 26. Create merge request via CodeCommits

Submit merge request

To submit the merge request there are a few questions to be answered generally the defaults are fine most of the time.

merge request create form
Figure 27. Create merge request via Branches

Review merge requests

View merge request

merge request create discussion 01
Figure 28. Merge request right after submission.

Add comment

merge request create discussion 02
Figure 29. User Joe Developer adds a comment under changes.
merge request create discussion 03
Figure 30. Mary DevOps views comment and resolves thread.

Amend request

merge request create discussion 04
Figure 31. Create a suggestion
Amendments are only available if the option for Allow commits from member who can manage the target branch has been checked during merge requestion submission.
merge request create discussion 05
Figure 32. Suggestion ready for review or application.
merge request create discussion 06
Figure 33. After suggestions have been applied two commits are present
merge request create discussion 07
Figure 34. The suggestions is now part of the merge request

Merge the request

merge request create discussion 08
Figure 35. Merge the request

Post merge review

Eventually the merge request was merged in this particular case with the Squash commits option checked.

It is now time to find out how the project repository changed.

Web UI post merge review

merge request create discussion 10
Figure 36. Project overview page post merge.
merge request create discussion 11
Figure 37. Review of the commits present.

git command post merge review

$ git pull origin main (1)
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 1), reused 2 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), 664 bytes | 664.00 KiB/s, done.
From https://gitlab.local:9480/jdev/gitlab-project
 * branch            main       -> FETCH_HEAD
   63388c0..a343d37  main       -> origin/main
Updating 63388c0..a343d37
Fast-forward
 README.md | 6 ++++(2)
 1 file changed, 4 insertions(+), 2 deletions(-)
$ git log (3)
commit a343d37672c6c73efea85a7100340057ca7a4858 (HEAD -> main, origin/main, origin/HEAD)
Merge: 63388c0 2142406 (4)
Author: Joe Developer <joe.developer@gitlab.local>
Date:   Tue Sep 26 00:40:53 2023 +0000

    Merge branch 'documentation' into 'main'

    Add email address to contributors

    See merge request jdev/gitlab-project!8

commit 214240696453302969ee67e364fa206d5dda5e65
Author: Mary DevOps <mary.devops@gitlab.local>
Date:   Tue Sep 26 00:40:53 2023 +0000

    Add email address to contributors

commit 63388c0fd88b803af36e8c158139edde98c05830
Merge: 2c34e69 c7b7c33
Author: Joe Developer <joe.developer@gitlab.local>
Date:   Thu Jul 1 09:55:50 2021 +0000

    Merge branch 'feature1' into 'master'

    New Install instructions 123

    See merge request jdev/gitlab-project!7

[.notes]
--
<1> Pull the changes from the GitLab project to the previously
    created repository.
<2> The file `README.md` is updated during this procedure.
<3> The `git log` command displays a bit more information about
    commit `5717883`. This is a merge commit with multiple parents.
<4> The merge line display all the parents this particular commit has.
    Merge commits can be prevented in under `Settings` -> `General` ->
    `Merge requests` -> (*) Fast-forward merge.
--

// vim: set colorcolumn=80 textwidth=80 spell spelllang=en_us :

// vim: set colorcolumn=80 textwidth=80 spell spelllang=en_us :

<<<