Skip to main content

Command Palette

Search for a command to run...

Git for Beginners

Basics and Essential Commands

Published
3 min read
Git for Beginners

If you are new to coding and find Git confusing, don’t worry. This blog will help you understand Git step by step using simple explanations and easy examples.

Git helps developers track changes in their code. It makes it easy to manage projects and fix mistakes. In this blog, we will learn Git basics and important commands step by step using simple examples.


Introduction to Git (For Absolute Beginners)

If you are new to coding and find Git confusing, don’t worry.
I was also confused when I first heard about Git. But after learning the basics slowly, it started making sense.

In this blog, I will explain Git in very simple words using easy examples.
This blog is written from a beginner’s point of view.


What is Git?

Git is a tool that helps developers track changes in their code.

When we work on a project, we change files many times:

  • we add new code

  • we remove old code

  • we fix bugs

Git keeps a record of all these changes.

In simple words, Git tells us:

  • what was changed

  • when it was changed

  • who changed it

So if something goes wrong, Git helps us understand what happened.


Why is Git Used?

Git is used because it makes coding safe and organized.

Here are some simple reasons:

  • Git saves the history of your code

  • You can go back to an old version if something breaks

  • Many people can work on the same project together

  • It keeps your project clean and managed

Because of this, Git is used by almost every developer.


Git Basics and Important Terms

Before using Git, it is important to understand some basic terms.


Repository (Repo)

A repository is your project folder.

Git watches everything inside this folder.

Example:
A folder named my-website that has HTML, CSS, and JavaScript files is a repository.


Commit

A commit is a saved version of your code.

Think of it like taking a photo of your project at one point in time.

Example:
After fixing a bug or adding a feature, you save your changes using a commit.


Branch

A branch is a separate copy of your project.

It helps you try new things without affecting the main code.

Example:
You create a new branch to work on a new feature while the main branch stays safe.


HEAD

HEAD shows the version of the code you are working on right now.

Example:
HEAD usually points to the latest commit or the current branch.


Staging Area

The staging area is like a waiting room.

Files stay here before they are finally saved.

Example:
Before committing, you add files to the staging area to choose what should be saved.


Common Git Commands (Easy Explanation)


git init

This command starts Git in your project folder.

git init

After this, Git starts tracking your project.


git status

This command shows:

  • which files are changed

  • which files are ready to be saved

git status

It helps you understand what is happening in your project.


git add

This command adds files to the staging area.

To add all files:

git add .

Now these files are ready to be committed.


git commit

This command saves your work with a message.

git commit -m "first commit"

The message helps you remember what you changed.


git log

This command shows all the commits made in the project.

git log

You can see who made changes and when.


Conclusion

Git is a very helpful tool for developers.

In this blog, we learned:

  • what Git is

  • why Git is used

  • basic Git terms

  • some important Git commands

If you practice these basics, Git will slowly start feeling easy.

Keep learning and keep practicing 😊

Happy Coding 🚀