GitLab vs GitHub: Know your Go to Platform ( GitHub vs GitLab)

Well, nowadays mostly people in IT need some form of coding and automation skills to manage Infrastructure such as Amazon cloud deployments, Azure deployment or applications deployments on datacenter. Yes you heard it right, certainly you need a way to store the code.

The code cannot be kept on your local machines as many people simultaneously work and to efficiently manage your code , versions of code you need a proper way. To achieve this we have two best products in market that is GitLab and GitHub.

This side shanky and in this yet another GitLab vs GitHub: Know your Go to Platform tutorial, I am going to give you in depth overview and detailed knowledge about both products GitLab and GitHub. Rest I leave up to you to consider which one suits you better after going through this entire tutorial.

Lets dive in right now.


This guide will have some practical’s in between so make sure you to have following things before in hand.

  • GitLab account and GitHub Account.

Table of Content

  1. Prerequisites
  2. What is GitLab?
  3. How to access GitLab?
  4. GitLab installation
  5. What is GitLab runner and GitLab Runner Installation
  6. Configure GitLab Runner Configuration
  7. GitLab Runner Docker
  8. GitLab Runner SSH
  9. GitLab Runner Commands
  10. GitLab Namespaces
  11. GitLab Access Management
  12. Configure LDAP in GitLab
  13. Configure AWS Cognito in GitLab
  14. Authenticating with GitLab from Git
  15. Git Credential Manager
  16. Create a personal access token in GitLab
  17. Clone GitLab repository using personal access token 
  18. Creating a Project Label in GitLab
  19. Git Commit in GitLab
  20. Creating first GitLab CI/CD pipeline
  21. Configure GitLab Pipelines: Declaring Variables , Rules in GitLab Jobs
  22. Declaring Services in GitLab Jobs
  23. GitLab code Dependency scanning
  24. GitLab code scanning in containers
  25. GitLab Environments and Deployments
  26. Authenticate GitLab with AWS
  27. What is GitHub?
  28. Getting started with your GitHub account
  29. How to access GitHub?
  30. What is GitHub Desktop
  31. GitHub Webhooks
  32. Authenticating with GitHub from Git 
  33. GitHub HTTPS Authentication with GitHub cli
  34. GitHub HTTPS Authentication with Git Credential Manager
  35. Generating Personal Access Token in GitHub
  36. GitHub code scanning
  37. GitHub code scanning in containers
  38. Advance GitHub code scanning
  39. GitHub Status
  40. GitHub Pricing
  41. Conclusion

What is GitLab?

GitLab is a code hosting platform for collaboration and version control. GitLab platform allows you to deliver software faster and efficiently, while strengthening security and compliance.

How to access GitLab?

You can access GitLab using various option as shown below.

  • GitLab SaaS: You can simply use this by signing in.
  • Install GitLab Self Managed your own instance.

GitLab installation

You can install GitLab on several cloud providers, or use one of the following methods.

  • You can install GitLab using Linux Package, Helm chart, Docker (The GitLab Docker images are monolithic images of GitLab running all the necessary services in a single container.), Source.
  • You can install GitLab on AWS, GCP, Azure.
# Ubuntu/Debian
sudo apt update && sudo apt install gitlab-ee

# RHEL/CentOS 6 and 7
sudo yum install gitlab-ee

# RHEL/CentOS 8
sudo dnf install gitlab-ee

sudo zypper install gitlab-ee

Note: GitLab is developed for Linux-based operating systems. It does not run on Microsoft Windows.

What is GitLab runner and GitLab Runner Installation

GitLab Runners are the agents that are responsible for all of the running CI/CD pipelines and GitLab CI/CD features.

GitLab Runner can be installed and used on GNU/Linux, macOS, FreeBSD, and Windows. You can install it in a container, by downloading a binary manually or by using a repository for rpm/deb packages.

To install GitLab on ubuntu and Linux Operating system first you need to add repo and use apt-get command.

  • Add the official GitLab repository:
curl -L "" | sudo bash
curl -L "" | sudo bash
  • Now run the below commands.
sudo apt-get install gitlab-runner
sudo yum install gitlab-runner

Configure GitLab Runner Configuration

To configure more settings in GitLab runner you can modify (config.tml) file on the below locations.

/etc/gitlab-runner/  # This is for unix machines
./ # on other systems

GitLab Runner Docker

  • Lets checkout the configuration for where we need to specify the volume for a docker container.
  host = ""
  hostname = ""
  tls_cert_path = "/Users/ayufan/.boot2docker/certs"
  image = "ruby:2.7"
  privileged = false
  disable_cache = true
  volumes = ["/path/to/volume/in/container"]

GitLab Runner SSH

  • Configure SSH connection with GitLab runner.
  host = "my-production-server"
  port = "22"
  user = "root"
  password = "production-server-password"
  identity_file = ""

GitLab Runner Commands

GitLab runner command allows you to register, manage and run your builds. Lets checkout quickly few of important commands that one should know to perform actions on GitLab commands.

  • To take help from GitLab runner commands.
gitlab-runner --help
  • Run Gitlab runner with debug mode on.
gitlab-runner run --debug
  • To register GitLab runner.
gitlab-runner register --name my-runner --url --registration-token my-registration-token
  • To Run GitLab runner as service.
gitlab -runner install --service myservice --syslog true --working-directory ~/mygitlabrunner --user root  --password ***
gitlab-runner uninstall  # This command stops and uninstalls GitLab Runner from being run as an service.
gitlab-runner start        # This command starts the GitLab Runner service.
gitlab-runner stop       # This command stops the GitLab Runner service.
gitlab-runner restart   # This command stops and then starts the GitLab Runner service.
gitlab-runner status    # This command prints the status of the GitLab Runner service

GitLab Namespaces

If you need to organize your projects accordingly then you can create a namespace. Different projects with different requirements or configurations can be kept within different namespaces.

The namespace for user account is:<user&gt;

GitLab Access Management

GitLab contains various projects and within projects members are created which are either user or groups. Each member gets role assigned to it so that they can access the projects accordingly. User can be part of single group or multiple groups.

When your project belongs to a group, project members inherit their role from the group. With group access tokens, you can use a single token to, Perform actions for groups, manage the projects within the group.

Note: However you cannot use group access tokens to create other group, project, or personal access tokens.

Configure LDAP in GitLab

This section is a optional as it requires higher level authentication where users login to GitLab using AD SSO.

  • To configure LDAP in GitLab edit the /etc/gitlab/gitlab.rb file as shown below and save the file.
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = {
  'main' => {
    'label' => 'LDAP',
    'host' =>  '',
    'port' => 636,
    'uid' => 'sAMAccountName',
    'encryption' => 'simple_tls',
    'base' => 'dc=example,dc=com',
  • reconfigure GitLab
sudo gitlab-ctl reconfigure

Configure AWS Cognito in GitLab

To enable the AWS Cognito OAuth 2.0 OmniAuth provider, register your application with Cognito. This process generates a Client ID and Client Secret for your application. To enable AWS Cognito as an authentication provider, complete the following steps. You can modify any settings you configure later.

  1. Sign in to the AWS console.
  2. From the Services menu, select Cognito.
  3. Select Manage User Pools and then in the upper-right corner, select Create a user pool.
  4. Enter the user pool name and then select Step through settings.
  5. Under How do you want your end users to sign in?, select Email address or phone number and Allow email addresses.
  6. Under Which standard attributes do you want to require?, select email.
  7. Configure the remaining settings to suit your needs. In the basic setup, these settings do not affect GitLab configuration.
  8. In the App clients settings:
    1. Select Add an app client.
    2. Add the App client name.
    3. Select the Enable username password based authentication checkbox.
  9. Select Create app client.
  10. Set up the AWS Lambda functions for sending emails and finish creating the user pool.
  11. After creating the user pool, go to App client settings and provide the required information:
    • Enabled Identity Providers – select all
    • Callback URL – https://<your_gitlab_instance_url>/users/auth/cognito/callback
    • Allowed OAuth Flows – Authorization code grant
    • Allowed OAuth 2.0 Scopes – emailopenid, and profile
  12. Save changes for the app client settings.
  13. Under Domain name, include the AWS domain name for your AWS Cognito application.
  14. Under App Clients, find your app client ID. Select *Show details to display the app client secret. These values correspond to the OAuth 2.0 Client ID and Client Secret. Save these values.

Authenticating with GitLab from Git

You need a way to authenticate to GitLab from Git and to accomplish this below sections will guide you to authenticate.

Git Credential Manager GitLab

In case of Git over HTTPS, Git Credential Manager (GCM) offers an alternative to personal access tokens. By default, GCM authenticates using OAuth, opening GitLab in your web browser.

Once it’s installed and configured, Git Credential Manager is called implicitly by Git. You don’t have to do anything special, and GCM isn’t intended to be called directly by the user

Create a personal access token in GitLab

Personal access tokens can be an alternative to OAuth2 and used to:

  • Authenticate with the GitLab API.
  • Authenticate with Git using HTTP Basic Authentication.

You can create as many personal access tokens as you like.

  1. In the upper-right corner, select your avatar.
  2. Select Edit profile.
  3. On the left sidebar, select Access Tokens.
  4. Enter a name and optional expiry date for the token.
  5. Select the desired scopes.
  6. Select Create personal access token.

Clone GitLab repository using personal access token 

Its important to know how to clone a repository using PAT. Lets checkout below command.

git clone https://<username>:<personal_token>

Note: When 2Factor Authentication is enabled, you can’t use your password to authenticate with Git over HTTPS or the GitLab API. You can use a personal access token instead

Creating a Project Label in GitLab

With labels, you can organize and tag your work, and track the work items you’re interested in. Lets dive in and see how to create Labels in GitLab.

  • Navigate to GitLab, then to Main menu and projects then project information.
  • Create a new Label.

Git Commit in GitLab

Commit message: A commit message identifies what is being changed and why. In GitLab, you can add keywords to the commit message to perform one of the following actions:

Creating first GitLab CI/CD pipeline

Before we create the the pipeline, lets learn some basic terms first.

  • CI (Continuous Integration): Pushing changes in code such as scripts etc. multiple times a day can introduce the risk so each change submitted to an application, even to development branches, is built and tested automatically and continuously. 
  • CD (Continuous delivery): Not only is your application built and tested each time a code change is pushed to the codebase, the application is also deployed continuously. Continuous Delivery checks the code automatically, but it requires human intervention to manually and strategically trigger the deployment of the changes
  • CD (Continuous deployment) is another step beyond Continuous Integration, similar to Continuous Delivery. The difference is that instead of deploying your application manually, you set it to be deployed automatically.

Make sure, before you start creating your first GitLab CI/CD pipeline, you have:

  • At least one GitLab runner active.
  • A project in GitLab
  • The Maintainer or Owner role for the project.
  • To check if GitLab runner is available navigate to Settings and then to CI/CD.
  • Create a blank Dockerfile in the repository. The job will run on GitLab Docker executor.
  • Next, create a .gitlab-ci.yml file so that runner can structure and order of jobs. On the left sidebar, select Repository > Files and create the file and copy/paste the below code.
    • Each Job each has a specific Stage and stage defines the sequential execution of the Jobs. Jobs, which define what to do and Stages, which define when to run the jobs.
    • Use needs keyword to run jobs out of stage order.
    • Use rules to skip the jobs or specify when to run the job.
    • Use the default keyword to specify additional configurations that are applied to all jobs.
    stage: build 
       - echo "Hello, $GITLAB_USER_LOGIN"
    stage: test
       - echo "Testing CI/CD Pipelin test Job 1"       
    stage: test
       - echo "Testing CI/CD Pipelin test Job 2"
    stage: deploy
       - echo "Deploy from the $CI_COMMIT_BRANCH branch" 

  • You should have below files in the repository.
  • To View the status of your pipeline and jobs navigate to CI/CD and then pipelines.

  • Further to view the build job logs, click on it.
  • Note: variables: To push a commit without triggering a pipeline, add [ci skip] or [skip ci]

Configure GitLab Pipelines: Declaring Variables , Rules in GitLab Jobs

  • To add variables in the GitLab job.
    value: "staging"
      - "production"
      - "staging"
      - "canary"
    description: "The deployment target. Set to 'staging' by default."
  • To add rules and workflow in the GitLab job. Rules apply to specific job however workflow apply to entire jobs.
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'

    - echo "This job runs in merge request pipelines"
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'

    - echo "This job also runs in merge request pipelines"
  • GitLab CI/CD job token

When a pipeline job is about to run, GitLab generates a unique token and injects it as the CI_JOB_TOKEN predefined variable. You can also use the job token to authenticate and clone a repository from a private project in a CI/CD job. You can call on project from another project.

git clone https://gitlab-ci-token:${CI_JOB_TOKEN}<namespace>/<project>

Declaring Services in GitLab Jobs

When you configure CI/CD, you specify an image, which is used to create the container where your jobs run. To specify this image, you use the image keyword.

You can specify an additional image by using the services keyword. This additional image is used to create another container, which is available to the first container. The two containers have access to one another and can communicate when running the job.

    - bundle install

  image: ruby:2.6
    - postgres:11.7
    - bundle exec rake spec

  image: ruby:2.7
    - postgres:12.2
    - bundle exec rake spec

GitLab code Dependency scanning

The Dependency Scanning feature can automatically find security vulnerabilities in your software dependencies while you’re developing and testing your applications.

  - template: Jobs/Dependency-Scanning.gitlab-ci.yml

GitLab code scanning in containers

By including an extra Container Scanning job in your pipeline that scans for those vulnerabilities and displays them in a merge request, you can use GitLab to audit your Docker-based apps.

To enable container scanning, add the Container-Scanning.gitlab-ci.yml template to your .gitlab-ci.yml file. Also make sure GitLab CI/CD pipeline must include the test stage. If you’re using a third-party container registry, you might need to provide authentication credentials through the CS_REGISTRY_USER and CS_REGISTRY_PASSWORD configuration variables.

  • Below template builds your Docker image, pushes it to the container registry, and scans the image.
  - template: Jobs/Build.gitlab-ci.yml
  - template: Security/Container-Scanning.gitlab-ci.yml


GitLab Environments and Deployments

Environments describe where code is deployed. Each time GitLab CI/CD deploys a version of code to an environment, a deployment is created.

    stage: build 
       - echo "Hello, $GITLAB_USER_LOGIN"
    stage: test
       - echo "Testing CI/CD Pipelin test Job 1"       
    stage: test
       - echo "Testing CI/CD Pipelin test Job 2"
    stage: deploy
      name: staging
       - echo "Deploy from the $CI_COMMIT_BRANCH branch" 

Authenticate GitLab with AWS

To use GitLab CI/CD to connect to AWS, you must authenticate. After you set up authentication, you can configure CI/CD to deploy.

  1. Sign on to your AWS account.
  2. Create an IAM user.
  3. Select your user to access its details. Go to Security credentials > Create a new access key.
  4. Note the Access key ID and Secret access key.
  5. In your GitLab project, go to Settings > CI/CD. Set the following CI/CD variables:Environment variable nameValueAWS_ACCESS_KEY_IDYour Access key ID.AWS_SECRET_ACCESS_KEYYour secret access key.AWS_DEFAULT_REGIONYour region code. You might want to confirm that the AWS service you intend to use is available in the chosen region.
  6. Variables are protected by default. To use GitLab CI/CD with branches or tags that are not protected, clear the Protect variable checkbox.

What is GitHub?

GitHub is a code hosting platform for version control and collaboration. You can perform below tasks within GitHub using Version control system ( VCS) called Git.

  • Create and use a repository
  • Start and manage a new branch
  • Make changes to a file and push them to GitHub as commits
  • Open and merge a pull request

Getting started with your GitHub account

To sign up for an account on, navigate to and follow the prompts. To best use GitHub, you’ll need to set up Git. Git is responsible for everything GitHub-related that happens locally on your computer. 

Organizations are shared accounts where businesses and open-source projects can collaborate across many projects at once.

GitHub provides two types of Enterprise products:

  • GitHub Enterprise Cloud
  • GitHub Enterprise Server

The main difference between the products is that GitHub Enterprise Cloud is hosted by GitHub, while GitHub Enterprise Server is self-hosted.

How to access GitHub?

You can access GitHub using following methods. Note make sure you have git already installed and to download go to

  • GitHub CLI to use GitHub from the command line. To install GitHub CLI follow here.
  • GitHub Desktop client that work locally but not on command line.
  • Gitbash
  • Browse to
  • GitHub API
  • GitHub Mobile is available as an Android and iOS app. To install go here

What is GitHub Desktop

With GitHub Desktop, you can interact with GitHub using a GUI instead of the command line or a web browser. You can use GitHub Desktop to complete most Git commands from your desktop, such as pushing to, pulling from, and cloning remote repositories, attributing commits, and creating pull requests, with visual confirmation of changes.

You can download GitHub Desktop from

GitHub Webhooks

Webhooks allow you to build or set up integrations, such as GitHub Apps which subscribe to certain events on When one of those events is triggered, we’ll send a HTTP POST payload to the webhook’s configured URL.

Webhooks can be used to update an external issue tracker, trigger CI builds, update a backup mirror, or even deploy to your production server.

When configuring a webhook, you can use the UI or API to choose which events will send you payloads. 

  • Go to settings on the repository.
  • Navigate to Webhooks and click on Add Webhook.
  • The payload URL is the URL of the server that will receive the webhook POST requests from the Github. Setting a webhook secret allows you to ensure that POST requests sent to the payload URL are from GitHub.

Note: You can configure to receive webhooks with GitHub CLI using below command.

gh extension install cli/gh-webhook

Authenticating with GitHub from Git 

GitHub HTTPS Authentication with GitHub cli

GitHub CLI will automatically store your Git credentials for you when you choose HTTPS as your preferred protocol for Git operations and answer “yes” to the prompt asking if you would like to authenticate to Git with your GitHub credentials.

gh auth login

GitHub HTTPS Authentication with Git Credential Manager

Git Credential Manager (GCM) is another way to store your credentials securely and connect to GitHub over HTTPS. 

The next time you clone an HTTPS URL that requires authentication, Git will prompt you to log in using a browser window. Once you’ve authenticated successfully, your credentials are stored in the Windows credential manager and will be used every time you clone an HTTPS URL. Git will not require you to type your credentials in the command line again unless you change your credentials.

GCM is included with Git for Windows. During installation you will be asked to select a credential helper, with GCM listed as the default. Once it’s installed and configured, Git Credential Manager is called implicitly by Git. You don’t have to do anything special, and GCM isn’t intended to be called directly by the user. 

To install Git Credential Manager , follow here.

Password-based authentication for Git has been removed in favor of more secure authentication methods use Personal Access Token. 

Generating Personal Access Token in GitHub

A token that is used in place of a password when performing Git operations over HTTPS with Git on the command line or the API. Also called a personal access token.

When you git clonegit fetchgit pull, or git push to a remote repository using HTTPS URLs on the command line, Git will ask for your GitHub username and password. When Git prompts you for your password, enter your personal access token.

For example, on the command line you would enter the following:

$ git clone
Password: YOUR_TOKEN

Note: Personal access tokens can only be used for HTTPS Git operations. If your repository uses an SSH remote URL, you will need to switch the remote from SSH to HTTPS.

GitHub code scanning

You can use code scanning to find security vulnerabilities and errors in the code for your project on GitHub. To do code scanning you can use CodeQL analysis and third party pools.

  • CodeQL is the code analysis engine developed by GitHub to automate security checks. You can analyze your code using CodeQL and display the results as code scanning alerts.

To setup code scanning follow the below steps.

  • On, navigate to the main page of the repository and go to settings.
  • You can also integrate third party tools to scan your code such as Dependency Review.

GitHub code scanning in containers

If you’re configuring code scanning for a compiled language, and you’re building the code in a containerized environment, the analysis may fail with the error message “No source code was seen during the build.” This indicates that CodeQL was unable to monitor your code as it was compiled.

You must run CodeQL inside the container in which you build your code. 

name: "CodeQL"

    branches: [main]
    branches: [main]
    - cron: '15 5 * * 3'

    name: Analyze
    runs-on: ubuntu-latest
      security-events: write
      actions: read

      fail-fast: false
        language: [java]

    # Specify the container in which actions will run
      image: codeql-container:f0f91db

      - name: Checkout repository
        uses: actions/checkout@v3
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v2
          languages: ${{ matrix.language }}
      - name: Build
        run: |
      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v2

Advance GitHub code scanning

  • On, navigate to the main page of the repository.
  • Under your repository name, click  Actions.
  • Add new workflow.
  • Configure CodeQL Analysis and commit below yml.

GitHub Status

To get a status of entire GitHub about your projects and repositories you can access GitHub status website using

GitHub Pricing

There are three plans available for GitHub as shown below.

  • FREE PLAN: Free of cost: The basics for individuals and organizations.
  • TEAM PLAN: Around $4 per month for one user which includes Advanced collaboration for individuals and organizations.
  • Enterprise PLAN: Around $20 per month for one user which includes Security, compliance, and flexible deployment


In this tutorial you learnt everything you should know to understand GitLab and GitHub and how these two products just makes your life as simple as breathing. GitHub is not open source however GitLab is an open source product.

Also in this tutorial you learn various concept that helps you identity how both product works and their features.

Now that you have sound knowledge about these products, so where do you plan to host your code in your next assignment?


The Ultimate Guide for beginners: Getting started with Git commands

One of the best version control that I have used so far for managing multiple repositories and files in a smooth and distributed . The open source tool which we are talking here is Git the best control version. Please follow along to know the more on on how to work with Git , setup Git on ubuntu and windows machine & best commands and setup guide.

This tutorial is going to add a lot of valuable knowledge on Git in your pockets, Stay tuned !!

Table of Content

  1. Getting Started with Git
  2. Create a new git repository using graphical interface on GitHub
  3. Creating a new git repository using command line on ubuntu machine
  4. Getting Started with Git Commands for beginners
  5. Summary

Getting Started with Git

What is Repository ?

Repository is a place where you keep all your source code it could be project wise or you can create it for a particular technology or you can create even for a single file, it all depends on you and your requirement. Its always a good idea to provide the name of repository according to work which you are going to do. There are some cloud based source code tools which allows you to create your repositories such as bitbucket , GitLab, GitHub ,Subversion , SVN and Mercurial etc. where you can create your own repositories.

Create a new git repository using graphical interface on GitHub

  • Before we create the first repository make sure you have GitHub account created . If you don’t have please click here and Sign up.
  • If you have access to it then open your browser and go to GitHub website from here and click on Sign in.
  • Now click on New button to create a new repository
  • Now, provide a suitable name of the repository and you may keep it as public open to world if you wish people can see your code else keep it private. We are keeping as public as this is a demo tutorial and finally select create repository.
  • Now your repository is ready to be used. Please make sure you below steps which we will use later in this tutorial.
    • create a new repository on the command line and
    • push an existing repository from the command line

Creating a new git repository using command line on ubuntu machine

  • You must have ubuntu machine preferably 18.04 version + and if you don’t have any machine you can create a ec2 instance on AWS account
  • Recommended to have 4GB RAM
  • At least 5GB of drive space
  • SSH into your ubuntu machine
  • Now create a folder under /opt directory
cd /opt
mkdir git-demo
cd git-demo/
  • Initialize your new repository
git init
  • Create a file inside the same directory using the command
echo "My first change" > adding-new-file.txt
  • Now check the status of git repository using the command
git status
  • Add the file in git repository using the command
git add .
  • Again check the status of git repository using the command
git status
  • Commit your changes in git repository using the command
 git commit -m "MY FIRST COMMIT"
  • Add the remote repository which we created earlier as a origin.
git remote add origin
  • Push the changes in the remote branch ( Enter your credentials when prompted)
git push -u origin master
  • Now Verify if the text file which we created is present in repository

Getting Started with Git Commands for beginners

Here we will work with most important commands of Git. Let us work with same directory which we created earlier.

cd /opt
mkdir git-demo
cd git-demo/
This image has an empty alt attribute; its file name is image-300.png
  • Check the status of the repository
git status
  • Add a file in the directory and run the command
echo "Adding new file again" > second_file.txt
  • Now check the status of repository again, it should show untracked files as they are added in repo yet
  • Add files in repository by using command
git add .
  • Check the status of git again
  • To check the status of git with short status
git status -s
  • Now edit the file which we created and check the status .
    • You will notice that there will be two things one is changes to be committed because we already added them using git add.
    • Also you will notice changes not staged for commit because we recently edited our file but didn’t add it.
echo "I am editing my second file " >> second_file.txt
  • Add the file in repository which we modified.
git add .

git status
  • Although we know that we modified a line and checked the status , but if you want to check the difference between the two you can use command.
git diff        # Git diff provides the information which is not committed
  • Also you can check the committed change so far by using the command.
git diff --cached      # Git diff --cached provides the information what is committed
  • Commit all your changes
git commit -m "Committing all my changes" .       # m here means message
  • To delete your staged file properly, that is how to delete those files which are already committed
git rm second_file.txt  # This command will also remove the file from the directory
  • If you wish to delete your staged file properly but keep the file in the directory for future use
git rm --cached second_file.txt  # This command will not remove the file from the directory
  • To check history of your commits in a git repos use a command
git log  # The command gives the list of commits in reversal order which is expected.
  • To check history of your commits with the difference between each commit we use -p flag
 git log -p -2    # -p stands for patch that is difference and 2 here is last 2 commits
  • There are some more commands to view the commits in more presentable way , lets checkout.
git log --pretty=format

git log --pretty=format:"%h %s" --graph


You should now have a very sound knowledge of what Git is , how to create Git repository using graphical mode as well as using command line tool . Also we discussed how to work with Git repositories using different commands. This tutorial consists of all the practical’s which were done on our lab server with lots of hard work and efforts.

Please share the word if you like it and hoping you get benefit out of this tutorial.

You can also visit : Introduction-to-git-a-version-control-getting-started-with-git-step-by-step

Introduction to Git Version control and Getting Started with Git step by step

Are you tired of taking backups of your multiple files and facing syncing errors of your files ? Do you have any central place where you can store your files with proper versions and history ? Most of us faced this issue of file sync issues or how to control you same files with some updates. Git is a version control which solves all these issues & has grown the popularity for the way it works .

In this tutorial we will discuss what is version control , what are types of version controls and how to install git a version controller on windows machine and then setup to working with it.

Table of Content

  1. What is Git ?
  2. How to Install git version 2.31.0 on Windows machine?
  3. Three types of control versions
  4. Setting up Git Bash on windows machine
  5. Summary

What is Git ?

Git is a version control which means if you have lots of file and each of these files are updated with few changes from the previous one then you need some way to handle it and this is taken care very well by Git. Sometimes you need to revert the changes back to previous state or you need to check few things of a month back , those all things are maintained by version control very well.

Three types of control versions

  • Local control version – In this case you take files from version control database to your local machine it’s just like a copy from one folder to other. In this case no team member knows what you are doing.
  • Centralized control version – In this case you can checkout files from centralized location which is better than local control as team is aware about the project and what team members are doing but in case if server goes down nobody will have full backup as in complete repository data and can cause significant loss. Example: SVN, subversion
  • Distributed control version: This is version control which manages everything in distributed way that means when you clone any repository it takes all data of one repository and copies on your local machine. Git is among the distributed control version

How to Install git version 2.31.0 on Windows machine

  • Open your browser and click on the link here so that installation starts automatically.
  • Now Click on the downloaded Git-2.31.0-64-bit.exe and select YES
  • Follow along with me and click the Next button and in most of the case select default values which are already selected
  • Select the location on your system where you like to place GIT installation files.
  • It is better to add it on Desktop
  • Please select the recommended
  • Here you will be asked to choose SSH executable and select OpenSSH. This will allow us to work with SSH connections such as logging into Linux machine.
  • Use MinTTY as default
  • Finally Git is launched on your machine and GIT bash will be available to use.

Setting up Git Bash on windows machine

  • Let us verify is Open SSH is working from Git Bash.
  • Now, you can check the config file where you can modify some configurations if required and to check that run the command below.
git config --list --show-origin
  • You can modify the global name while using Git by using below command
  • Check all your settings by using command
git config --list


You should have a basic knowledge of what Git is and how it’s different from any centralized version control systems you may have been using previously. You should also now have a working version of Git on your system that’s set up with your personal identity.