Develop Software in Team with Git and Gitlab

Mother of all version control

We all know that building software is hard. Building software in team is much harder… until Git come to the rescue!

What is Git(Lab) ?

Git is an open-source distributed version control, initially developed in 2005 by Linus Torvalds, the creator of Linux kernel. In a nutshell, Git traces changes in our code, which we call as repository. Git also has a feature called branch. Git branch is a pointer to specific changes in our repository. In a simpler term, Git branch works exactly like a tree’s branch that attached to the trunk (central part of the code, usually the one that was deployed to production environment).

Gitlab is a DevOps platform that was built under Git specification. Gitlab provides many features to increase developers productivity such as Git repository hosting on the cloud. It also provides built in CI/CD features that is easily integrated with wide range of servers, either cloud based or on premise.

One of the advantages of Gitlab instead of another Git services is the ability to host a Gitlab instance by our own for free. Gitlab is available for self hosted installation due to its open source license. In University of Indonesia, we use our self-hosted Gitlab for the Software Engineering Project course to ensure isolation of the code and easier integration of account generation using UI SSO service.

Gitlab for Software Development in Team

Note: Knowledge of basic Git commands is necessarily needed before working with Git in team.

While working with Git in team, there are some branches that are involved in the overall development process. Those branches are:

  1. One primary branch (named main or master). This branch contains the primary code that was deployed to the production environment.
  2. From the primary branch, a branch was derived to store the code that was deployed to staging server. This branch commonly named as develop. This branch will be merged to master after all features candidate passed the manual and automatic testing.
  3. Developers often works on the features or code refactors in a feature branch. These branches were made by deriving it from the staging branch. After the code has been tested, we will merge it to staging branch.
  4. If there is a critical bug that needs a fix, developers will do the fix in a branch named hotfix. This branch is derived from the master branch and can be merged immediately to the master branch without merging it to develop branch.
Gitflow used in the SE Project Course @ Fasilkom UI

Connecting The Branches — Introducing Merge Request

After working on the features inside a separated branch we need to integrate these changes with the overall codebase. Before deploying it to production environment, it is necessary to deploy it to the testing environment first.

The staging environment code is sitting inside the develop branch. To deploy our feature to the staging environment, we need to make a merge request from feature branch to develop branch. Merge Request is a feature provided by Gitlab that allows team to see changes of the merge candidate code, give comments to the changes, and approve the changes before merging it to other branch.

Example of a Merge Request in the SIKEPA Backend Service

To ensure a good quality of code, we enforce a unit testing pipeline and code smell detection using SonarQube. The merge candidate also need to be approved by another members before can be merged to the develop or master branch. More details of CI/CD will be covered in another article.

For easier communication with teammates regarding to MR checking, we also integrate Gitlab to Discord using webhook to send message to a Discord channel on every MR made.

Conclusion

Git and Gitlab makes our software development easier, especially when working with teams. To achieve an effective software development, Git Flow is utilized so every team member has a standard on developing and operating Git as a version control and collaboration tool.

Thank you for reading this blog, see you soon with another blog series of PPL 2022!

--

--

--

palugada software engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Visualizing Bitcoin prices moving averages using Dash

Serverless is Taking Off: Here’s Why It’s Worth Hopping On

PixelPlex: The Development Powerhouse Behind SAVAGE

[New Coin Listing] COTI(COTI) to Be Listed on DigiFinex

Adding Nx to an Existing Monorepo by Running One Command

Testing the Performance of a Pricing Optimization Model — My practicum journey with Engage3

Euler Theorem in its core!

How to connect to Raspberry Pi via ssh without password (using ssh keys)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Samuel Nainggolan

Samuel Nainggolan

palugada software engineer

More from Medium

REST Services

Simple Approach to Error Handling in Python (Application in GUI Programming)

What I Learned at Work this Week: Accept-Language HTTP Header

Using a proxy to capture http requests in dotnet

The modal for enabling capture of requests in postman