Git it! - Simplified Git Tutorial (Part 1).

WTF is Git? How to install and setup?

Posted by Aashish Kumar on May 05, 2020 · 6 mins read

If there is a tool or software that every software developer must know, it is GIT. Everyone will agree that we all struggle with it initially when we start learning it. So I’m here to ease the burden from the shoulders of the beginners, who are just starting with this amazing tool.

Let’s Git it!

We’ll be learning the following topics today:-

  1. Understanding Git (How it Works?)
  2. Installation and Setup
  3. How to Commit!
  4. Git + Github
  5. Branching and Merging
  6. Rebasing
  7. Squashing

Note:- This is part 1 and contains only the first two of the mentioned topics. Head to part 2 for the next topics.

Understanding Git (How It Works?)

Git is an actively maintained open-source version control system, which was developed by Linus Torvalds - The father of Linux foundation, in 2005. Its source code can be easily found on github. It is a great command-line tool which is quite tricky to understand initially, but once you get it, you’re no less than a superhero :p.

By version control system, it means that it maintains the checkpoints of your project i.e different versions. The checkpoints in git are known as commits. Whenever you make changes in any line of your code, you need to commit these changes to create a checkpoint in your project.

The feature that makes git powerful is the fact that you can maintain these checkpoints in a branched manner, and not just in a linear fashion. By branching the checkpoints, I meant this:-

Branching different features

The circles are the commits/checkpoints, and different branches signify different features in the project. The main advantage of branching is that you can separately work on a branch, without interfering with the commits or work in other branches. This way you can work on many features/parts of your project independently.

These branches can be merged and can be controlled. Each project has a default master branch which contains the main workflow of your project. There are many features that git supports like rebasing, reverting, cherry-picking, squashing, merging, etc. We’ll learn a few of them today.

As you now know about the basic workflow of git and how it works (trust me, telling more than this at a beginner level will only confuse you, now you know enough to get started). Let’s not waste any more time and get started with it.

Installation and Setup

1. Installation

Git is pretty easy to install in all Linux, Unix, and windows based operating systems. Nowadays it comes pre-installed in the OSes. So to check if it is already installed, run the following command in your terminal (Mac/Linux), command prompt (windows), to check the version of git installed.

git --version

If the output is something like:

git version 2.7.4

Then it’s already installed, and you can skip to the next part (setup). If not then do the following based on the type of OS you are using:

Linux (Ubuntu)

Run the following commands:

Update your package index first.

sudo apt update

Install git.

sudo apt install git

Run the version command in terminal to confirm if it’s installed:

git --version

Unix (Mac-OsX)

There are two ways you can install git here, either you can download the Git Installer for Mac and run it and follow the prompts to install it, or you can use homebrew to install it. Run the following command:

brew install git

Run the version command in terminal to confirm if it’s installed:

git --version


Download the Windows Installer for Git, and run it. Follow the prompts to install git successfully.

Run the version command in command prompt to confirm if it’s installed:

git --version

2. Setup

Now that you’ve successfully installed git in your system, you need to add a username and email for your git. Run the following command to add them:

git config --global "Aashish Kumar"
git config --global ""

Now you need to set up a git repository in a folder in which you want to have version control. Open the folder in terminal/command prompt and run the following command:

git init

This will initialize a new git repository in your folder. You can now see a folder named .git, created in your directory. If you are unable to see it, then press Ctrl + H or Cmd + Shift + . (Mac) to show the hidden items, and now you’ll be able to see the folder.

This folder is hidden by default because you don’t need to touch any files in this folder. Now that you’ve initialized your first repository, it’s commit time <3.

Booyah! You’ve completed Part 1. Now head to Part 2 to learn how to use git.

Note:- If you think there is anything wrong with the tutorial, or you can modify something, feel free to point out in the comments or raise an issue.