Basics of Git , Explained .

thewires2 profile image Arnavbagchi Updated on ・2 min read

I am going to be talking about the basics of version control using git in this blog. Version control allows you to store the different versions of a project when it is under development. For example - You add a new feature to your project but it does not work out. Git allows you to restore the previous version of the project which was working properly.

It is especially helpful when working on large projects and it has advanced tools to help teams collaborate.

Installing git is a very simple task in Linux

$ sudo apt install git-all

You will need to configure git once its installed.

Initialising a repository

Create a simple python file which prints Hello World and store it into an empty directory called practice

Python File

Enter the directory in the terminal and initialise a repository using the command

$ git init

Initialising the repository

Checking Status

Before we do anything further we shall look at the project's status using the command

$ git status


Master is the main branch of the project.

Adding files to the repo

In the next step we shall add the python file and check the projects status again using the commands

$ git add .
$ git status

Adding the file

Making a commit

Lastly but most importantly , we will commit the python file to our repo using the command

$ git commit

When we enter this command , git will ask us to write a message for the commit stating whats its function. We will write First commit as our message

Message editor

Successfull commit

After committing the changes we will look at the status of our project again using

$ git status


Reversing a commit

We shall add another line print("abc") to our original file

Add Line

Now we shall check status of project


We shall now follow all the commands given above on how to make a commit

$ git add .
$ git commit
$ git status

Second commit

Now say we want to revert the changes and have the previous state of the file. We will use the checkout command to revert the project back to its previous stage.

$ git revert (commit hash)

These were the basics to getting started with version control , i will be making more detailed blogs in future posts.

Hey there !
I am Arnav , an engineering student hailing from Mumbai.

Posted on by:

thewires2 profile



I'm an engineering student. I'm interested in coding.


markdown guide

Thanks for the post.

I think your last 2 screenshot are identical (no 'checkout' result screenshot.)

As someone who has (very late) just started using git, it's nice to cover the basics.


My bad , I will edit the post as soon as possible✌🏼