Getting started with Gitlab for beginners

  • Create Gitalb Account
  • Install Git in your local machine
  • Configure SSH to pull & Push files to Gitlab
  • Create your first project
  • Clone the project to your local machine
  • Create example code file
  • Push code to Gitlab
  • Make changes in your code
  • Push to Gitlab
  • Create new branch locally & push to Gitlab
  • Pull changes from Gitlab, Make changes & Push the code
  • Merge the code to master branch

For getting started with your first Gitlab project, You have to create a project on Gitlab, Detailed steps to create Gitlab account & setup your first Gitlab project is given here. Once you finished setting up your first project, let’s fetch the code to your local machine. You can import the code in any preferred IDE such as Visual studio & can edit the code. Let’s start with fetching the code first to the local machine.

Open your project on & click on clone button. We are using SSH to clone the project, click on clone with SSH & copy the URL.

Open the folder in your machine, Right click on it & click on Git Bash Here. This will open the Git terminal in your working directory. In the terminal we have to paste the command which we had copied earlier. Your command will look like this,

Git clone

This will clone the project from Gitlab to your local directory. This will take time to download the project depends on your project size & internet bandwidth. If you are just starting up with Gitlab, this will be very quick.

Once the project is cloned into your local directory. CD into the new project folder which got created. Command will be,

cd <folder name which is cloned from gitlab>

Additionally to see the files & folder, You can use the command, ls -la

We have to initialize the git project first before we start working on it. To do this, Type,

git init

Now the project is initialized. You can copy any text file or or source code folder to the working directory. Let’s assume you have copied abc.txt file to the working directory folder. Our task is to push this file successfully to our project in Gitlab.

To check the files copied or created the in project folder, git status command will list the status for us. This will show the files in red which are not committed & pushed to the Gitlab. Git status

Its time to add files, to add all the files at once before we commit.

Git add .

You can again check the status of the files after we have added those. This will show the files added in green.

Git Status

The files are added now, Please hold on, this are not comitted & pushed yet to the gitalb server. While committing the files, you can add comment. The comment will help to understand what we have added or changed in the code for future reference. So please do not miss to add the comment as best practice.

git commit -m “This is comment example, abc file added in the project”

Finally it’s time to push the code to our main branch. We are currently in our main branch, you can check the branch

Git push

You have pushed all your files to the gitlab, Please refresh your gitalb projects page to see the files, Thanks for reading 😉

Leave a Comment