Beginners guide to setup GitLab in 4 simple steps

Getting started with GitLab plays a critical role in efficiently managing your projects, sharing code, tracking bugs, accomplishing your CI/CD missions.

You need to understand GitLab, create an account and project. Lastly, it would help to manage a simple repository on the terminal and website. Let's dive into getting started with GitLab.

Advertisement

 

Understanding GitLab’s building technology

One of the steps to getting started with GitLab is understanding GitLab and distinguishing it from git.

Git is the technology that powers GitLab. It is a distributed version control system (DVCS), letting contributors have a copy of the project in their local machines.

Git workflow starts by initializing an empty repo or cloning one. You then create files and track them through staging and committing changes. If multiple developers work on the project, they can independently open and modify files on a branch and inject the changes in the main branch through merging, pushing and pull requests.

Since local files can easily get lost, it would be best to push the changes to a remote cloud server like GitLab. GitLab is a code-tracking cloud server that applies git. Its most familiar alternatives are GitHub and Bitbucket.

Now that you know what we will work with while getting started with GitLab, let's go ahead and create a GitLab account before doing some workflow practice.

 

Pre-requisites

We will be using a Linux box with git installed to manage the gitlab repo

Advertisement

 

Step-1: Creating a GitLab account

Navigate to GitLab's website.

Click on Login if you don't plan to subscribe to a paid service. That is because clicking on Get Free Trials demands later spending some money before hosting your code on GitLab.

On the Login page, you will see a message, Don't have an account yet? Register now next to the Sign in button. Click on Register now. The link takes you to the Register page, where you should click on Register.

Wait for the GitLab account creation confirmation email and click on the link. The link takes you to GitLab's login page, where you can log in, in readiness to continue getting started with GitLab through SSH key pairs generation.

 

Step-2: Generate SSH key pairs

Secure Shell is a safer way to connect your machine to a remote computer or server. Without it, you cannot push changes to GitLab. Neither can GitLab allow you to pull changes from or clone repositories.

You should also configure the keys because they simplify getting started with GitLab push without constantly retyping your username and password.

Advertisement

The security of the SSH depends on the hashing algorithm used to generate the keys. The most secure types are RSA and EdDSA. EdDSA key type is the most secure and is more manageable than the RSA.

Let's create an EdDSA key type by running the ssh-keygen command on your terminal.

ssh-keygen -t ed25519 -C "<comment>"

Here, -t stands for the key type, whereas -C implies a comment. The comment uniquely identifies the key. I am creating one as follows.

ssh-keygen -t ed25519 -C "Getting started with GitLab"

cd into the .ssh folder, cat, and copy the public key.

cd .ssh

cat id_ed25519.pub

Beginners guide to setup GitLab in 4 simple steps

Move to the GitLab account. Click on your profile photo -> Preferences.

Beginners guide to setup GitLab in 4 simple steps

Paste the key in the text area. Specify the expiry date, then click on Add key. Now that your GitLab account is created and SSH configured, it is ready for local and remote development.

Advertisement

 

Step-3: Getting started with GitLab by creating a project

One of the most crucial steps to getting started with GitLab is to create a project. Sign in to your GitLab account. Click on New project followed by Create blank project.

Beginners guide to setup GitLab in 4 simple steps

Enter project name, (optional) description, type (public or private), and (optional) README.md, then click on Create project

Getting started with GitLab

 

A public project means anyone can view the branches and files. A private GitLab project, on the other hand, means only those permitted can view the project details. A README.md file describes the project. Use it to tell your potential audience the project's purpose.

After creating the project, also known as the repository, GitLab notifies you of the successful progress. If you created a README.md file, you would see 1 commit, 1 branch, and a blue button named Copy SSH clone URL.

Beginners guide to setup GitLab in 4 simple steps

 

Otherwise, you get instructions on setting an upstream and pushing changes to the newly created repository. Let's proceed with getting started with GitLab by managing the new project.

 

Step-4: Managing a project using the terminal and GUI

The kernel of getting started with GitLab is knowing how to create files, stage and commit the changes, branching, merging, and handling pull requests. Here's a brief explanation of the terms before seeing their practical usage.

Advertisement

Staging a change is temporarily storing it in the index before committing or undoing it. Committing a change creates a unique record in the git database.

Branching is creating independent development lines to ease collaboration. You do that by accumulating changes in the sub-project, staging, and committing them.

When done with sub-project, you ask the project manager to inject the changes into the main branch, a process called creating a pull request. Once the manager is satisfied with the changes, they join the branch with the main one; a process called merging.

Let us see the terms practically through the terminal and a GUI on the GitLab website. Before that, you should install and configure git for your operating system.

 

Using CLI to manage gitlab projects

Get the project files by clicking on Clone followed by Clone with SSH. Head over to your terminal and clone the repo.

Beginners guide to setup GitLab in 4 simple steps

Cloning a repository means downloading the updated project files and folders on your local machine.

Advertisement

 

Branching

cd into the cloned project, then create and checkout a branch by running the switch command

cd get_started

git switch -C second_branch

Beginners guide to setup GitLab in 4 simple steps

 

Create a file

touch file

 

Stage the file

git stage file

 

Commit the changes

git commit -m "Add file"

 

Merge the changes

Checkout the main branch and merge the changes.

git checkout main

git merge second_branch

Beginners guide to setup GitLab in 4 simple steps

 

Push the changes

Push the changes through the main branch.

git push

Beginners guide to setup GitLab in 4 simple steps

Refreshing the remote shows our new changes.

Beginners guide to setup GitLab in 4 simple steps

 

Using GitLab GUI

Let's repeat the above steps using the GitLab workflow.

 

Branching

Click on the dropdown next to the project name and choose New branch. Beginners guide to setup GitLab in 4 simple steps

Advertisement

 

Enter branch name and tap on Create branch.

Beginners guide to setup GitLab in 4 simple steps

Create a file and commit changes

In GitLab, staging and committing a file are bundled into saving.

Click on the dropdown next to the project name and choose New file. Name the file. Add some content, then scroll down the page and commit the changes, clicking on Commit changes.

Beginners guide to setup GitLab in 4 simple steps

Beginners guide to setup GitLab in 4 simple steps

Merging

Click on Create merge request on the repository's landing page.

Beginners guide to setup GitLab in 4 simple steps

 

(Optionally) change the commit message, write a short description, then scroll down and click on the Create merge request button.

Beginners guide to setup GitLab in 4 simple steps

 

That is all you who do as a branch creator. The next step entails the actions of a project manager.

Click on Merge. Otherwise, tap close or edit from the Options dropdown.

And that is all to know when getting started with GitLab.

 

What is more?

Getting started with GitLab can be pleasurable when you understand Git and GitLab workflow then do some practice, as shown in this tutorial. Now is the time to enjoy your development with GitLab.

 

Didn't find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment

X