Skip to main content

Command Palette

Search for a command to run...

Git for Beginners: Basics and Essential Commands

Published
5 min read
Git for Beginners: Basics and Essential Commands

When you start learning programming, one of the big challenges is keeping track of your code. You make changes, something breaks, you forget what you changed, and sometimes you even lose code that was working.

That's where Git comes in handy.

Git helps you keep track of your code changes, save different versions of your project, and work safely without worrying about losing your work. Almost every software company and developer uses Git, so getting to know it early is a really smart idea.

In this blog, I'll explain Git in simple terms, just like one student teaching another.

What is Git? (In Simple Words)

Git is a version control system.

Simple meaning:

Git helps you save the history of your code.

Every time you make a change, Git can take a snapshot of your project. Later, you can:

  • Go back to older versions

  • See what changed

  • Know who changed what

  • Fix mistakes easily

Git is also a distributed system, which means every developer has a full copy of the project history on their own computer. You are not fully dependent on one central server.

You can think of Git like a time machine for your code.


Why Git is Used

Git is used because it solves many real problems for developers.

Git helps you:

  • Track changes in your code

  • Go back to previous versions

  • Experiment without fear

  • Work in teams safely

  • Keep backup of your project

  • Understand project history

For example, if you break your project today, you can simply go back to yesterday’s working version using Git. That alone makes Git extremely valuable.


Git Basics and Core Terminologies

Before using commands, you should understand some basic Git words.


Repository (Repo)

A repository is a project that is tracked by Git.

It contains:

  • Your project files

  • Git history

  • Git configuration

When you run Git in a folder, that folder becomes a Git repository.

Think of a repository as:

Your project + its full history.


Commit

A commit is a saved snapshot of your project at a specific time.

When you commit, you are saying:

“This is a stable point. Save it.”

Each commit has:

  • A unique ID

  • A message

  • A snapshot of files

Think of a commit like:

Saving a game checkpoint 🎮 (without emoji style, but conceptually)


Branch

A branch is a separate line of development.

It lets you:

  • Work on new features

  • Fix bugs

  • Experiment safely

without breaking the main code.

The main branch is usually called main or master.

Branch helps you work on things without disturbing stable code.


HEAD

HEAD is a pointer to your current position in Git.

Simple meaning:

HEAD tells Git which commit you are currently on.

When you switch branches or go to older commits, HEAD moves.


Git Working Areas (Very Important Concept)

Git has three main areas:

  1. Working Directory

  2. Staging Area

  3. Repository (Commit History)


Working Directory

This is where you edit your files.

When you change code in your editor, it is in the working directory.

Git knows files are changed, but not saved in history yet.


Staging Area

Staging area is like a waiting room for changes.

You select which changes you want to include in the next commit.

This gives you control.


Repository (Git History)

This is where committed changes are permanently saved in Git history.

Once changes are in the repository, you can always go back to them.


Common Git Commands (Beginner Friendly)

Now let’s see the most important Git commands you will use as a beginner.


git init

This command creates a new Git repository.

git init

It tells Git:

“Start tracking this project.”


git status

This command shows the current state of your project.

git status

It tells you:

  • Which files are changed

  • Which files are staged

  • What is ready to commit

This is one of the most used Git commands.


git add

This command moves changes to the staging area.

git add filename

or to add all files:

git add .

It tells Git:

“These changes are ready for the next commit.”


git commit

This command saves staged changes into Git history.

git commit -m "your message here"

The message should explain what you changed.

For example:

git commit -m "Add login page UI"

This creates a new snapshot of your project.


git log

This command shows commit history.

git log

It shows:

  • Commit IDs

  • Author

  • Date

  • Commit messages

This helps you understand project history.


A Basic Developer Workflow Using Git

This is how most beginners and professionals use Git daily.

  1. Create or open a project folder

  2. Run git init

  3. Create or edit files

  4. Check status using git status

  5. Stage changes using git add

  6. Commit changes using git commit

  7. Repeat this process

This simple loop is the heart of Git usage.


Simple Example

Let’s say you create an HTML file.

  1. Create index.html

  2. Run git status to see changes

  3. Run git add index.html

  4. Run git commit -m "Add homepage"

Now Git has saved your work safely.

If you mess up later, you can go back to this commit.


Why Every Beginner Should Learn Git Early

Git is not just a tool. It is a core developer skill.

Learning Git early helps you:

  • Work like a professional

  • Avoid losing code

  • Understand real project workflows

  • Prepare for internships and jobs

  • Work confidently on bigger projects


Final Words for Beginners

Git may look confusing at first, but it becomes very simple with practice.

You don’t need to learn everything at once.

Start with:

  • git init

  • git status

  • git add

  • git commit

  • git log

Master these basics first. After that, learning branches and remote repositories will be much easier.

Think of Git as your safety net and project memory. Once you get used to it, you will never want to code without Git.