Are They “Gitting” Back Together?!

Roshani Ayu Pranasti
pepeel
Published in
7 min readMar 9, 2020

Nowadays, teams all over the world who are not living under a rock use some sort of online repository to collaborate. Doing a team project means having multiple developers working in parallel. How do we keep up with all the changes made by each programmer? We use version control.

“What is version control?” you may ask. Version control is a tool that helps you control every change you want while keeping track of it. To put it simply, it is a way to help you communicate with other people, especially your team so they could see what changes you make in projects. A popular version control, such as Git, also provides more helpful features that will help you work fluently in teams.

In PPL course, we are using GitLab which is basically an online repository that uses Git version control. Why do we need version control? From what I’m experiencing with my team (Group A8), I feel a collaboration arises unconsciously every day. Everybody in the team is able to work freely on any file at any time. The version control system will allow my team’s members to merge all changes into a common version.

GitLab as a Project Management App

My team is developing a website application, we called it Document Builder. In our GitLab group, we only have one repository that consists of front-end (React.js) and back-end (Node.js). The repository has a deployment branch or known as a master branch, staging branch, development branch PBI[1..n], and a rollback branch called coldfix.

For the record, we can also use GitLab to manage our project development flow (aren’t you amazed?!). Its feature called the GitLab board.

My team chooses the desired product backlogs based on their priorities. Then, the chosen product backlogs are split into tasks and each task is assigned to a team member. The tasks are listed by the scrum master in the GitLab board. With the GitLab board, it makes it easier for my team to know which tasks are on progress or finished and who is responsible for that task.

Document Builder’s GitLab Board

The Implementation of Git Flow

Initiate a Repository

First, I need a working directory on my local computer. Well, in this course, we had been provided the repository by our scrum master, so there is no need to create another one. So what I need to do at first, is to clone it. Clone means we are going to copy it to our local computer using the clone URL.

In this case, I clone our repo pepeel URL (don’t forget to make sure that you already have the access to your repo)

git clone https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/pepeel-fhui-document-builder

Branching in Git

Branches are a useful system in Git to make sure every person in the team has their own workspace. This is a must, so there will be a lesser conflict if two or more people are working at the same time.

In my experience, once I cloned my team’s repo, I only had several branches like the master and staging branch in my local repository. To check my current branch location and shows what branches are available in my local, I use the command:

git branch

My team’s Git Flow may differ from others. We make this branch that acts like a pre-staging branch called PBI-[1..n]-[PBI Definition]. Then, we create our own development branch from the branch that matches the PBI our team trying to achieve.

In Sprint 1, my team’s only chosen CRUD Template as our goal of sprint. Assuming branch PBI-1-CRUD_template_surat is already initiated in the online repository (it’s in my case), I could move to that branch now, by typing this command:

git checkout PBI-1-CRUD_template_surat

Now I have moved to branch PBI-1-CRUD_template_surat. For Sprint 1, this branch is supposed to be recently most updated in our Git Flow. Then, I need to create my own branch to start working.

git checkout -b PBI-1/API_edit_template_surat

This will automatically switch to my own development branch that I had just made.

Getting Up-To-Dates

Sometimes, some people in your team already finished their work faster than you. Knowing that their work is already “submitted” to the main branch (in my case is PBI-1/API_edit_template_surat). I am expected to update my code, so I could get the latest from the system.

So, I pulled the PBI-1/API_edit_template_surat branch into my local repository using this command:

git pull origin PBI-1/API_edit_template_surat

This will have the contents of the PBI-1/API_edit_template_surat branch in my local repository.

After pulling some updates to my code, there could be some problems occurred. Some cases prevent me to pull because there are some lines of code that are different from your working branch. To solve it, I either need to stash the file or commit the code first.

Stashing My Work

Often, when you’ve been working on part of your project, things are in messy conditions. The problem is, you don’t want to do a commit of half-done work yet. The solution to this kind of problem is by using stash.

This kind of thing happened once when I was working to create an API for the edit letter template. I have already made a few changes in this branch, but then I need to work on my other crucial task which is making a header for our app. I didn’t think my code in the PBI-1/API_edit_template_surat is working already, so then I stash them before making my way to PBI-1/Component_header_dan_sidebar branch.

git stash

Stashing takes the dirty state of my working directory, which is my modified tracked files and staged changes, then saves it on a stack of unfinished changes that I can reapply at any time.

I can retrieve my stashed work by doing so:

git stash pop

“Saving My Progress”

After done working, and making some progress in my code. I might save it according to my own checkpoints in my implementation flow. I can do this by first adding which files I want to commit, by typing this command:

git add <directory/file_name>

or I can just use this command if I simply want to commit every change in my work.

git add .

Then, I am allowed to commit my added work. Remember, these committed files are saved locally on my computer. You can commit using this command:

git commit -m "commit message"

I will commit accordingly with the right commit messages and tags ([GREEN], [RED], [REFACTOR], [CHORES]) to my development branch. Below is the example of my commit message in order to finish the create header component task.

Examples of the Good Commit Message

Just to be clear, a good commit message should describe what you have done and what changes you made.

Submitting My Work

After committing a commit in my local repository, I will push my commit manually in my terminal using the command:

git push origin PBI-1/Component_header_dan_sidebar

You can commit a few commits before pushing them to your online repository, but it’s not a recommended practice to push that many commits in one time.

I have been implementing the following commands above for these past two weeks in order to get my tasks done. When I am sure that everything is ready at the end of Sprint 1, in the meaning of my assigned tasks are done, I will create a merge request to the parent branch of its PBI which is PBI-1-CRUD_template_surat (in my case).

To create a new merge request, go to Merge Request in Sidebar and click the “New merge request” button at the top right of the browser as seen below:

Create New Merge Request Button

Then, you will get asked which branch do you want to merge and also the target branch. After that, you fill in the description and other mandatory fields based on the origin branch. The merge request may look something like this:

Every merge request you submit has to be approved by your team members before you actually merge it. This way, they need to review your code and give any input on your work.

Example of Code Review by My Team Mates
An Approval from your Team Mates is Needed

When the tasks are merged, I update the issue status on the board so my team can easily see that my task is done.

There are lots of Git commands out there. Everything that explained above is just the basic commands in Git that I always use in getting my tasks done. If you know and understand them, I would say you’re good to go. In the following weeks, I hope to learn new commands about Git that will be useful for this project and the team.

You can also see those commands in this cheat sheet, if you wanna know other commands you can also visit this Git documentation.

--

--

Roshani Ayu Pranasti
pepeel
Editor for

Computer Science Student @ University of Indonesia