Learn Git And Github

what is git and github
Reading Time: 5 minute
Rate this post

Git is essential to the process of developing software in the modern era. Therefore, in today’s post, I will talk about what Git actually is and why it is such a helpful tool.

What is Git?

Git is a distributed version control system that is free and open source and is made to efficiently and quickly handle projects of all sizes.

What is Github?

GitHub is a platform for code hosting, version control, and collaboration. It allows you and others to collaborate remotely on projects.

What is the difference between Git and Github?

Git is a version control system that enables you to manage and monitor the history of your source code. GitHub is a cloud-based hosting service that enables Git repository management.

Why do we use Git And Github?

Imagine You’re working on a document, and I’m not necessarily talking about code here. It could be any document.

And you save the final version of that document. You call it Document Final, and then you relook at it the next day. Or you show it to a teacher and need to make some changes. Now, what do you do?

Do you save over the original document? In this case, you lose the original. So you probably create another version because you want to preserve that first document.

Now you saved the new version of this document. But if you have to change it again, then you will keep saving different versions of this file as it changes. And this is really pain full.

This is where version control comes in incredibly useful. You don’t have to save 15 or 20 versions of the same document. You have one document, And what Git will do is track that document as changes occur. 

And each time you make a significant change to the document.

You can use Git to take a snapshot of the document and add notes to that snapshot, explaining exactly what you did with that change and why you’re taking a snapshot at that point. And so, Git gives you the evolution of the document. 

And if after 15 or 20 or 100 updates of this document, you want to go back to version 15, you can do that and see what changes version 15 had. And that’s very useful. And not only that, you can revert to the document as it was at the state of 15, or 16 or at 20 or whatever iteration you want to return to.

The other thing it enables you to do is something called branching. So if you want to take the document off in a particular direction, but you don’t want that to affect the master version of the document, you can develop a branch of the document knowing that you’re not touching the master. The version that you don’t want to change.

And so, with coding, for example, that can be incredibly useful because you can keep the code that you know works. And then, if you want to develop little branches of that code, you can do so, and you won’t damage the master version of that.

And it’s also really useful if you want to collaborate as well, because different people can work on different branches and when they save it, they can add notes, so you know exactly what’s going on with that document. That’s why it’s incredibly useful.

And then, of course, it sets you up to push that document onto GitHub, where you can keep your documents and your code in perpetuity, and you can share that code with anyone you want. So that’s why it is incredibly useful, aside from being essential if you want to get a job.

How to Install Git

First, Click here and Go to The Git Download page. Then download Git for your operating system. 

After downloading, install Git like any other normal software.

So, now you have installed Git on your system. It’s time to learn some basic concepts of Git.

What is Git init?

If we want to use Git, we have to initialize it into our working directory. When we initialize a repository, it looks for changes in our file.

What is Git stage?

You must stage the file before the final commit when your work is done. Stage tells Git which of your changes should be included in the next commit. When you stage a file, you are finally prepared to commit. To stage all files, type the command git add . 

What is Git commit?

The git commit command takes a snapshot of the present state of the project’s development. To do this, type the command git commit and hit enter.

What is Git push?

The git push command uploads content from a local repository to a remote repository. For example, GitHub.

What is Git pull?

The git pull command retrieves data from a remote repository and update data in a local repository.

What is Git merge?

Using git merge, you can combine numerous commit chains into a single, consolidated history. Git merge is typically used to merge two branches together.

Now that you know some basic concepts of Git let’s start learning some Git commands.

15 GIT commands you should know

How to setup a git repository:

If you want to use it in a folder, you have to initialize it. To do this, open the command prompt and navigate to the directory and type the command:

git init

How to Add All Files to Git’s Staging Area

You can use a dot (.) to add every file in your project to the staging area. For example:

git add .

How to Check the Status of a Git Repository:

This command displays the current repository’s status, including staged, unstaged, and untracked files.

git status

How to commit changes in Git with a message:

It is possible to add a commit message without using the editor. This command allows you to enter a summary for your commit message.

git commit -m “your commit message here.”

How to view your Git commit history:

This command displays the history of commits for the current repository:

git log

How to undo unstaged Git changes:

git checkout filename

How to create a new Git branch:

You have one default branch, the main branch. This command allows you to create a new branch. Git will not automatically switch to it. you must do it manually

git branch branch_name

How to switch to a newly created git branch:

Use this command to switch to a different or newly established branch.

git checkout branch_name

How to list Git branches:

The git branch command allows you to view all created branches. It will display a list of all branches and highlight the current branch in green with an asterisk.

git branch

How to delete a Git branch:

git branch -d branch_name

How to combine two Git branches:

To merge the history of the current branch with the branch name, you must execute the following command:

git merge branch_name

How to add remote repository in Git:

git add remote https://repo_here

How to push modifications to a remote Git repository:

When you are ready to save your work to a remote repository, you can push all modifications using the command below:

git push

How to fetch modifications from a remote Git repository:

If other team members work on your repository, you can retrieve the most recent modifications using the command below.

git pull

Pushing a new branch to a remote repository using Git:

You can use the following command to push a branch to a repository Remember to add -u to establish the upstream branch:

git push -u origin branch_name

How to delete a remote Git branch:

If you no longer require a remote branch, you can delete it with the following command:

Git push –delete origin branch_name_here

Git comes with many more commands, and You can find all available git commands in the git documentation


Git and GitHub are quick and easy ways to keep track of projects, whether they are being worked on by a single person or a group of software developers. Even though GitHub has a lot of complicated features, it is easy for individuals and small projects that need a way to keep track of changes to use.

Leave a Reply

Your email address will not be published.