Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

How to use GitLab

What is GitLab?

GitLab is an open-source web-based Git repository that is a complete DevOps platform that
allows professionals to work on all kinds of tasks in a project, such as planning, code
management, monitoring, and security. It empowers team productivity and improves the
product life cycle, which adds value to the customer. GitLab is a DevOps platform that
allows monitoring source code, sharing work on multiple projects, and building more
optimized software.

● GitLab helps manage Git repositories on a centralized server.


● Git Commands are used in the Git repository
● It offers free public and private repositories, wikis, and issue-tracking.
● GitLab provides a Continuous Integration (CI) system to manage projects and user
interfaces with features of GitLab.
● It is a user-friendly web interface that increases the speed of working with Git.

Git Commands

Let’s check out some basic Git commands that are used to work with Git.

○ To check the version of Git, use the command below

$ git --version

○ To add a Git username to identify the author, use the command below-

$ git config --global user.name “USERNAME”

○ To verify the username, use the command below

$ git config --global user.name

○ To set the email address, use the command below-


$ git config --global user.email “email_address@example.com”

○ To verify the email, use the command below-

$ git config --global user.email

○ To add all the files, use the command below-

$ git add.

○ To view changes in red color and add the file, use the command below-

$ git add file-name

○ To check the changes made in the file, use the command below-

$ git status
○ To check the entire information list, use the command below-

$ git config --global --list

○ To create a new branch, use the command below-

$ git checkout -b branch-name

○ To switch from one branch to another, use the command below-

$ git checkout branch-name

○ To pull the latest changes to the master branch, use the command below-

$ git checkout master

○ To fetch the latest changes to the working directory, use the command below

Here, NAME-OF-BRANCH might be an existing branch or master branch

○ To send changes to the master branch, use the command below-

$ git push origin branch-name

○ To delete all changes, including untracked files, use the command below-

$ git clean -f
○ To merge the different branch with the master branch, use the command
below

$ git checkout branch-name

$ git merge master

How do I log in to GitLab?

To log in to GitLab, do the following steps:

1. Open about.gitlab.com
2. If you have an account, Sign in, or else Register.
3. You will get a Welcome page of GitLab
4. Click to create a project where developers work most in GitLab. Here we can create
projects, configure projects, and add files.
5. Creating a group in GitLab helps organize your projects and grants access to
multiple projects more quickly if we have dozens of documents on policies and best
practices for a developing team.
6. Explore Public Projects helps access a massive library of public GitLab projects.
GitLab supports you if you want to access public projects to find out how to organize
or to grab a copy of open source software and contribute.
7. Learn more about GitLab, which helps you access GitLab’s documentation and
guides to using the platform. It helps to create a project using CI/CD pipelines. Now,
let’s see how to create a project.

How do I create a project?

To create a project in GitLab, do the following steps:

1. On the above GitLab welcome page, click on Create a project.


2. We get a page with four options to create a project in GitLab.
3. Firstly, let’s create a blank project.
4. Enter the project name, enable the private visibility level, and then click Create
project.
5. An empty repository project has been created
6. Now open Git Bash and run the following commands that help to create a Git file,
configure the file, add a file, and push the file to the repository.
○ Configure your username using the command below
$ git config --global user.name “Keerthana_Jonnalagadda”?
○ Configure your email using the command below.
$ git config --global user.email Youremail@address.com?
○ Make a directory by using the command below
$ mkdir GLTutorial?
○ Configure the directory by using the command below.
$ cd GLTutorial?
○ Run the command
$ pwd?
○ You will get an empty folder link, representing that a folder has been created.
/c/Users/Lenovo/GLTutorial?
○ Now initialize the folder by using the command below.
$ git init?
○ Now let’s create a file by using the command below
$ touch Mindmajix.txt?
○ Run a Notepad file by using the command below
$ notepad Mindmajix.txt?
○ You will get a Notepad file named Mindmajix. Write a few words in the
filestatus
$ git status
○ Add the file
$ git add .?
○ Commit the file
$ git add .?
○ Check the status
$ git add .?
○ Now go to GitLab, click Projects dropdown in the menu, and open Your
Projects

Add remote origin


$ git remote add origin
○ Manish_Kumar_Srivastava/gitlab-tutorial.?
○ Fetch the file
$ git remote -v?
○ Push the file
$ git push -u origin master
7. Open GitLab, check Your projects, and you can see the “Mindmajix.txt” file, which
was created to push into the GitLab

Click on the “Mindmajix.txt” file.

8. You can see the data in the file

Likewise, we can push our files, folders, and records into GitLab.

Create from Template

1. We can also create a project using 24 in-built templates from different sources, like
Ruby on Rails, Spring, iOS Swift,.NET Core, and many more.
From the list of available in-built templates, click Preview to view the template
source, and click Use template to start creating the template. The rest of the process
is the same as creating a blank project. []

Create from Importing a Project

1. We can import projects from various Git and other sources to GitLab.

Create using CI/CD external repository

1. Instead of moving the entire project to GitLab, we can connect to an external


repository using a CI/CD external repo.
2. Choose GitHub or Repo by URL to connect with an external repository

How do I create a group in GitLab?

1. The group is a collection of projects that helps to manage and organize the projects,
like a folder. It helps to maintain group members access and permissions for each
project in the group. To create a group, follow the steps.
2. Open GitLab, click Groups on the top menu bar, and then click on New group to
create a group
3. You get a create group page; in that, enter your group name and click Create group.
4. The group was successfully created. Now, click on New Project to create projects in
the group.
5. Enter the project name and enable Private visibility level
6. The project Mindmajix has been successfully created.
7. Go back to the groups and check the project has been created
8. We can also add an avatar to our project and group name. Open project, click on
Settings and then click General
9. A general settings page opens. Choose project avatar, select your avatar, and click
Save Changes.
10. You can see the project avatar is updated.
11. We can also add an avatar while creating the project.

Add users to the group

Adding users to the group makes for organized work that benefits accessing files. Admin
can restrict the access of the user and can even schedule a time for a deadline to work on
the project. To add users to the group, do the following steps.

1. Open your group and click on Members in the group’s dashboard


2. Members page opens.
○ Enter GitLab member or email address to invite into the group.
○ We can choose the role of a particular member, such as guest, reporter,
developer, maintainer, or owner.
○ We can schedule the access expiration data, which helps organize the work.
And then click Invite to add the member to the group.
This way, we can invite members or users to the group.

Changing the owner of the group


The ownership of group members must have at least one owner. Changing the owner of a
group is only possible for one owner. To change the owner of the group, do the following
steps.

As a current owner

● Go to groups and click Members in the group dashboard.


● Assign different user owner permissions.
● Have a new owner sign in and remove owner permission from you (the owner).

As an administrator

● Go to groups and click Members in the group dashboard.


● Assign different user owner permissions.
● Now refresh the page. We can remove permissions from the original owner.

Remove members from the group

In GitLab, an owner is a person who manages the users of the group. So, only users with
the permission of the owner can also manage the group members.
To remove a member from the group, do the following steps:

1. In the group, click Members in the group dashboard.


2. Click the Delete button next to a group member to remove them. A remove member
window appears.
3. Enable Also, unassign this user from related issues and check the merge requests
checkbox.
4. Click Remove member.

Project forking workflow

A fork is a copy of an original repository that we make in the namespace and can apply
changes to later without affecting the original project. It takes a few steps to fork a project in
GitLab.

Create a fork
To create a fork, do the following steps:

1. On the project page, pick a project and click on the fork icon
2. Select the project to create a copy of the project.
3. The project has been forked successfully.

Request for merging

A merge request is a request to merge one branch to another, which means when we
create a new feature, change the files, and push into the GitLab, you need to create a
merge request. This process helps to update the changes made in the copy file and the
original file. To create a merge request, do the following steps.

1. Open projects, click Merge Requests on the project’s dashboard, and then click on
New Merge.
2. You will get a merge page. Select your source branch, click Compare Branch, and
continue.
3. A new merge request page opens. Give all the required details to merge, and click
Submit merge request.
4. A request has been sent to the person to merge the changes in the project.

Removing a fork

In GitLab, we can even remove the fork relationship that helps not to send merge requests
to the upstream project. Only project owners have permission to remove the fork from a
project. To remove a fork, follow the steps below:

1. Go to projects, Click on Settings, and then click General.


2. A General Settings page opens in that list; scroll down to Advanced and click
Expand.
3. An advanced settings page opens; scroll down to Remove fork relationship and click
on it.
4. A confirmation window appears. Type the project link to proceed, and click Confirm.

You might also like