Do you want to organize your project files using GitLab? If yes, then you are at the right place. This comprehensive GitLab tutorial will help you to learn from scratch. In an organization, there are lots of files and folders are required to maintain a project. GitLab places a crucial role to organize these files which are held by different people at different places.
GitLab is a robust and well-integrated Continuous Integration and Continuous Deployment (CI/CD) pipeline that helps developers to track changes in the files. It was launched in 2014 by GitLab Inc. came with ultimate features that make developers work easier. Now, let’s go further to learn more about GitLab.
GitLab Tutorial for Beginners
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 builds more optimized software.
- GitLab helps to 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.
Inclined to build a profession as GIT Developer? Then here is the blog post on Git Training Course.
|
Git Commands
Let’s check out some basic Git commands that are used to work with Git.
-
- To check the version of the Git, use the command below
$ git --version
-
- To add a Git username that is 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 to log in to GitLab?
To log in to the GitLab, do the following steps:
- Open about.gitlab.com
- If you have an account, Sign in or else Register.
- You will get a Welcome page of GitLab, as shown in the figure.
- Click to Create a project where developers work most in GitLab. Here we can create projects, configure projects, and can add files.
- Create a group in GitLab helps organize your projects and grants access to multiple projects more quickly if we had dozens of documents on policies and best practices for a developing team.
- Explore public projects helps to access a massive library of public GitLab projects. GitLab supports if you want to access public projects to find out how to organize or to grab a copy of open source software and contribute.
- Learn more about GitLab helps to access GitLab’s documentation, 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 to Create a Project?
To create a project in GitLab, do the following steps:
- On the above GitLab welcome, Click on Create a project.
- We get a four options page to create a project in GitLab, as shown in the figure.
- Firstly, let’s create a Blank project.
- Enter the Project name and Enable Private Visibility level, as shown in the figure, and then click Create project.
- An empty repository project has been created, as shown in the figure
- 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.
-
- Make a directory by using the command below
$ mkdir GLTutorial?
-
- Configure the directory by using the command below.
$ cd 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 naming Mindmajix. Write a few words in the file, as shown in the figure.
- Check the status
$ git status
7.Open GitLab, check Your projects, and you can see the “Mindmajix.txt” file which is created to push into the GitLab
as shown in the figure
Click on the “Mindmajix.txt” file.
8.You can see the data in the file, as shown in the figure.
Likewise, we can push our files, folder, and records into GitLab.
Create from Template
- We can also create a project using 24 in-built templates of different sources like Ruby on Rails, Spring, iOS Swift, .NET Core, and many more as shown in the figure.
From the list available in-built templates, click Preview to view the template source and click Use template to start creating the template. Rest the process is the same as creating a blank project.[]
Create from Importing a Project
- We can import projects from various Git and other sources to GitLab, as shown in the figure.
Create using CI/CD external repository
- Instead of moving the entire project to GitLab, we can connect to an external repository using a CI/CD external repo.
- Choose GitHub or Repo by URL to connect with an external repository
How to Create a Group in GitLab?
- The group is a collection of projects that helps to manage and organize the projects like a folder. It helps to maintain the group members access and permissions for each project in the group. To create a group, do follow the steps.
- Open GitLab, click Groups on the top menu bar, and then click on New group to create a group as shown in the figure
- You get a create group page, in that Enter your Group name and click Create group, as shown in the figure.
- The group was successfully created. Now, click on New Project to create projects in the group, as shown in the figure.
- Enter the project name and enable Private visibility level as shown in the figure
- The project Mindmajix is successfully created.
- Go back to the groups and check the project is created as in the figure
- We can also add an avatar to our project and group name. Open project, click on Settings and then click General as shown in the figure
- A general settings page opens. Choose project avatar and select your avatar and click Save changes.
- You can see the project avatar is updated.
- We can also add an avatar while creating the project.
Add users to the group
Adding users to the group makes an organized work that benefits time to access 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.
- Open your Group, click on Members in the group’s dashboard
- Members page opens, as shown in the figure.
-
- 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, and Owner.
- We can schedule the access expiration data that helps to organize the work in a schedule.
And then Click Invite to add the member into 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 by one owner. To change the owner of the group, do the following steps.
As a current owner
- Go to groups, click Members in the group dashboard.
- Assign different user Owner permissions.
- Have a new owner sign in and remove Owner permission from you(owner).
As an administrator,
- Go to groups, 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:
- In the group, click Members in the group dashboard.
- Click the Delete button which is next to a group member to remove. A remove member window appears.
- Enable Also unassign this user from related issues and merge requests checkbox.
- 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 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:
- On the project page, pick a project and click on the fork icon as shown in the figure
- Select the project to create a copy of the project.
- 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.
- Open projects, click Merge Requests on the project’s dashboard and then click on New merge.
- You will get a Merge page, Select your source branch and click Compare branch and continue.
- A New merge request page opens. Give all the required detail to merge and click Submit merge request.
- A request has been sent to the person for merging 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 of a project. To remove a fork, do follows the steps below:
- Go to projects, Click on Settings and then click General as shown in the figure.
- A General Settings page opens in that list, scroll down to Advanced and click Expand.
- An advanced settings page opens in that scroll down to Remove fork relationship and click on it.
- A confirmation window appears. Type the project link to proceed and click Confirm.
Conclusion
On winding up, GitLab is a user-friendly and open-source tool that helps to store the file and organize them more easily. It allows developers to coordinate easily to work on the project. GitLab is easy to manage and configure the projects, and it has relied on Git, where the number of users is not restricted and can create more building applications. We have learned the basic details of GitLab, How to create a project, group, and how to fork a project. I hope this tutorial has helped you to understand GitLab.