GitLab commands for beginners and everyday users

6 min readJan 11, 2022

Say Yes to simplifying education

You have been given a new project and here are a few tasks which you are expected to do:

  1. Download the production repository on your machine
  2. Make code changes in the code present in the repository
  3. Push your code changes to the cloud in the same repository
  4. Create a code review request
  5. Finally, add your code changes to the production repository

If you want to version control your hobby project, go ahead with GitLab.

Repository download is called cloning in the world of GitLab.


Many engineers work on a single project and they all contribute by writing their part of the code.

Allowing a conflict-free working environment. GitLab allows its user to create branches of a project.

One Master branch and multiple individual branches.

The Master branch is the branch where you can say that the production-ready codes or final code are kept.

Other multiple individual branches are branches of each coder which is a copy of the Master branch initially and then the coder can do code changes to the copied branch. A coder can create n number of copies and thus n number of branches.

But the master branch is only one and all the code changes made in other branches after a proper code review are merged to master.

Git Clone:

  1. The first step is to make sure you are cloning the “master” branch.
The green boxes guide you where to look for the master branch drop-down button and click on the blue clone box to copy the HTTPS link.

2. Clone the master branch on your machine

git clone

You will be asked to enter the username and the password while cloning the repository.

If the git repo is a project from your personal account then use your personal credentials.

Otherwise, if it is your office account then make sure you have the authentication rights with the username and password. If you do not have then create a request for the same.

Git Branch:

After cloning the master branch create a branch from the master branch.

In simple words create a copy of the master branch and give a new name to the copied branch.

1. Check the cloned code is a master branch code.

To ensure go inside the cloned folder and type the below command

git branch

The output should be what you see in the below image.

2. Create a new branch

  1. Before creating a new branch, pull the changes from upstream. Your master needs to be up to date.
git pull

You will be asked to enter your GitLab credentials one more time.

2. Create the branch on your local machine and switch to the new branch :

My new branch name is “correspondence_fixes”. You can give any name. The best way is to give it a feature name you wish to add or fix.

git checkout -b correspondence_fixes

3. Type the command git branch to check if you are on the new branch you just created.

Notice the green star on the line correspondence_fixes and that is how you know that you are now working on the new branch you just created.

Now start adding your code in the same folder you cloned without any fear.

Any of your code changes will not be added to the main production-ready code that you just cloned from the master branch.

Git add:

Hey, hope you had a good coding and you successfully added your code to the new branch you created.

Git status:

Now is the time to identify modified (edited), untracked(new files) files on your new branch to identify those files let's run the below command.

git status

In the above image, you can see that we added our code changes to two files. The files are and

Now as the instructions in the above image says use commands git add and then git commit.

We will use git add to add the modifications to the code in our branch and do not worry this will not get updated in the master branch/production code.

(venv) mylocal@machine:~/myproj$ git add myproj/

Once you have added the code now is the time to commit your code to your branch with a message.

Git Commit:

git commit -m "write in short why you are committing this code"

Git Push:

git push -u origin correspondence_fixes

Push your newly created branch to the cloud with your code changes and for that, we must use the key “-u”.

Use the above command to push the code to your GitLab repository with the same branch name you created.

You can see that you have your branch on the cloud now.

Git Merge:

Git Merge is a great way to allow your team to review your code changes or testing team to run their test cases before it is merged to the master/production branch and give feedback.

Git merge is extremely helpful to collect feedback and work on them and say no to code conflicts.

Create your merge request and allow your team to make a great production-ready code.

In git merge, we can select one or multiple code reviewers.

After they have added their feedback we can work on them and repeat the git clone, git branch, git status, git add, git commit, git push, git merge.

Git Checkout

Switch to an existing remote branch from the current branch you are in.

(myvenv) mymachine:folder$ git checkout another_existing_branchHEAD is now at 5f3efda add desired benchmark data and evaluation script

Delete a remote branch

git branch -a 
# *master
# test
# remote/origin/master
# remote/origin/test
git push origin --delete test
# To <URL of your repository>.git
# - [deleted] test



I use GitLab every day and many of us.

Anyone who is new to the GitLab world and has been requested by the team to use GitLab or any individual who wants to keep track (Version) of their hobby or personal code. Please go ahead with Github.

These headings that you see in the blog is the flow of GitHub.

Start coding and get on GitLab now. I have my commands handy now.

For more, you can learn from here.




Computer Vision contributor. Lead Data Scientist @ Love Data Science.