Git / GitLab for Beginners (What is it? How to use it?), Pushing and Commiting Code, branches, forks, clones & all you need to know to Collaborate with your code

A minimalistic black and white icon representing GitLab, with the iconic fox in clean geometric lines, designed to look professional and recognizable.

Master version control and collaboration with GitLab

Introduction to Git and GitLab

What is git?

Git is a version control system that allows pople to work on a project simultaneously wihtout otherwriting each other’s changes. It helps you keep track of changes to your code, collaborate with others and revert to previous versions if needed.

What is GitLab?

GitLab is a web-based platform that provides Git repository management, code reviews, issue tracking and more. It helps teams collaborate on code and manage projects efficiently.

Why Push Code to GitLab?

  • Collaborate with others: Share your code with team members and work together on the same project.
  • Backup your code: Store your code in a remote repository to prevent data loss.
  • Track changes: Keep a history of changes made to your code, making it easier to understand and manage.

Creating a New Project in GitLab

  1. Log in to GitLab: Open your web browser and navigate to your GitLab instance (e.g., http://LOCALHOST).
  2. Create a New Project:
    • Click on the + icon or the New Project button.
    • Select Create a blank project.
    • Fill in the required details:
      • Project name: Enter a name for your project (e.g., stocktake).
      • Project slug: This will be automatically generated based on the project name.
      • Visibility Level: Choose the visibility level (e.g., Private).
    • Click on Create project.
  3. Get the Repository URL:
    • After the project is created, you will be redirected to the project page.
    • Copy the HTTPS URL of the repository (e.g., https://LOCALHOST/Andy.Naisbitt/stocktake.git).

Pushing Code to GitLab

Step 1: Initialize Git in Your Local Repository

# Navigate to your project directory
cd path\to\your\project
Initialize Git (if not already initialized)
git init

Step 2: Add the Remote Repository

# Add the GitLab repository as a remote
git remote add origin https://andy.naisbitt@MyGithubServerIPorDNS/Andy.Naisbitt/stocktake.git

Step 3: Add, Commit, and Push Your Code

# Add all files to the staging area
git add .
Commit the added files with a commit message
git commit -m "Initial commit"
Push the committed changes to the GitLab repository
git push -u origin master

What is a commit? A commit is like a snapshot of your project at a specific point in time. It records the changes made to the files in the project.

Why push code? Pushing code sends your local changes to the remote repository on GitLab, making it accessible to others and backing up your work.

Creating and Managing Branches

What is a Branch?

A branch is a separate line of development. The master branch (or main branch) is the default branch where the stable code resides. Creating branches allows you to work on new features or fixes without affecting the stable code.

Step 1: Create a New Branch

# Create a new branch and switch to it
git checkout -b new-feature

Step 2: Push the New Branch to GitLab

# Push the new branch to the remote repository
git push -u origin new-feature

Creating a Merge Request

What is a Merge Request?

A merge request (MR) is a way to propose changes from one branch to another. It allows team members to review the changes before merging them into the main branch.

Step 1: Create a Merge Request in GitLab

  1. Navigate to your project in GitLab.
  2. Go to Merge Requests and click New merge request.
  3. Select the source branch (e.g., new-feature) and the target branch (e.g., master).
  4. Fill in the details and create the merge request.

Additional Git Commands and Tips

Common Git Commands

git statusShows the current status of your working directory and staging area.
git branchLists all the branches in your repository.
git checkout branch-nameSwitches to the specified branch.
git merge branch-nameMerges changes from the specified branch into the current branch.

Using Git Credential Storage (Optional)

To avoid entering your username and password every time, configure Git to store your credentials securely:

git config --global credential.helper wincred


  1. Create a new project in GitLab.
  2. Initialize Git in your local repository.
  3. Add the remote repository URL.
  4. Add, commit, and push your code.
  5. Create and manage branches effectively.
  6. Use GitLab’s merge request feature to merge changes.
  7. Familiarize yourself with common Git commands.
  8. Consider using Git credential storage for convenience.

By following these steps, you can efficiently manage your projects and collaborate with your team using GitLab. Remember that practice makes perfect – the more you use Git and GitLab, the more comfortable you’ll become with version control and collaboration workflows.


GitLab is a powerful platform that can significantly enhance your development workflow and team collaboration. As a beginner, you’ve now learned the essential steps to get started with GitLab:

  • Understanding the basics of Git and GitLab
  • Creating and managing projects
  • Pushing code to repositories
  • Working with branches
  • Creating merge requests

Remember that GitLab offers many more advanced features as you grow more comfortable with these basics. Continuous integration, issue tracking, and project management tools are just a few examples of what you can explore next.

As you continue your journey with GitLab, don’t hesitate to refer back to this guide and explore GitLab’s official documentation for more in-depth information. Happy coding, and may your projects thrive with GitLab!

If you found this guide helpful, please consider sharing it with your colleagues or on social media. For more developer tips and tutorials, don’t forget to subscribe to our newsletter!

Join Our Community!

🌟 Get exclusive insights and the latest IT tools and scripts, straight to your inbox.

πŸ”’ We respect your privacy. Unsubscribe at any time.

Andy N

Information Technology Support Analyst with over seven years of experience (in the telecommunications and manufacturing industries) ranging from user support to administering and maintaining core IT systems.

Related Posts