Quick Git introduction with basic git commands for developers

Listen as audio
Image by Jae Rue from Pixabay

Hello Techies,

In this blog, I’m covering git introduction with basic git commands. So don’t worry, if you are searching How to download source code from git I will help you to clear your all doubts related to Git.

These are some basic questions that are raised in every software programmer’s mind because some of us might have heard this word from some experienced person and others who join a company recently in IT and they get some GitHub related work but they don’t have any idea about it.

Git introduction with basic git commands

What is Git?

Git is an open-source and free tool. It is created by Linus Torvald. Yes, your guess is right, he is the same guy who created the Linux kernel.

So in this world, there are millions of developers and everyone is trying to work on one software. Is it that easy to manage? No!!! It is very difficult. Let’s take an example where 5-6 peoples are working on one project so, everyone will find it difficult to handle that project, as they are not aware of GIT.

So he came up with a concept called GIT. In git, he handles all those things like merging of source code from different people and maintaining versioning. These kinds of features are provided by GIT.

How does this Git get work?

Git is a Distributed Version Control System. First, let’s quickly check what is the Distributed Version Control System? As I said Git provides a good feature that is versioning which means we can keep the track of each version of our Software on Git. 

Okay, Let’s say you get a project with some requirements and you successfully created that project. Now, what next? Sometimes it happens that, the client again calls you and says hey, there are some more features to be added in this software. So then we again start to work on the same project and add new features and you show it to your client and your client says oh these new features are not good for us. this happens right!!! Now you will remove all those features from the project.

In the first step you have created a project with some basic features and in the second step, you have added some extra features to the same project. But the new features do not match with the application that’s why you removed it from the project. Let’s say after some days your client says the added new features were awesome now we want those features as well. What will you do? you will again write the same code or if you have saved this deleted code somewhere, you will use it. You will keep a copy with versions on hard, But don’t you think you are doing lots of work?

So why do you have to manage all those things? If you have a very powerful tool here, which maintains all the versions for you and that is your version control system.

So in the Distributed version control system, every single developer has a copy of all versions with all the commits history with all of its branches in their local machine. Developers can work locally on their machine and they can push this data once the works get finished.

How to implement GIT

So far we have seen what Git is and how it works. Now you may be wondering how to implement GIT. So there are multiple implementations like Github, GitLab, Bitbucket by using one of these implementations you can create the account and create one repository in it. 

So these are some important points about the GIT. Now we will check how to download a copy directly from git and some basic commands like clone, pull, add, push, etc…

How to download the GIT Repository directly from Github or any other implementation platform

Most of the developers keep their repository as public so anyone can download it. So you will get the option either you can clone it or Download the repository zip so by clicking on Download zip you get the downloaded repository zip on your machine.

Now we will check git commands step by step.

Git command on command line

First of all, if you want to use git command from the command line, Git must be installed in your machine. For example, if you are using Windows, install Git Bash to use git bash commands and if you are using Ubuntu, you can install Git using the following command.

sudo apt install git

How to clone any repository from git

Copy the https: URL from the drop-down and use the below git command to a create repository copy in your machine.

git clone https://github.com/user_name/project_name.git

Git command to add the file to the staging area

git add <filename>

Git command to add one or more files

git add *

Git command to commit the file to head

git commit -m "Commit message"

Git command to pull updated files from the branch

git pull 

Git command to check the status of files

git status

Git command to push code

git push origin <branchname>

Git command to list all branches 

git branch

Git command to create a new branch and switch to it

git checkout -b <branchname>

Git command to switch from one branch another

git checkout <branchname>

So this is all about Git introduction with basic git commands. I hope you learned something new from this blog.

Leave a Comment