Git for Beginners: Basics and Essential Commands

After surviving the pendrive era, the next logical question was:
“Okay, version control makes sense… but how do I actually use git?”
This blog is a continuation of my previous article, “Why Version Control Exists: The Pendrive Problem.” Once you understand why version control is necessary, the next step is learning git: The tool that made modern collaboration possible.
If you are a beginner, student, or someone who feels git is hard or confusing, this article is for you.
What is git?
Git is a distributed version control system.
In simple words:
- Git helps you track changes in your code, remember every version, and collaborate with others without overthinking work.
Unlike the pendrive or zip approach, git helps us:
Keep a full history of changes
Allows multiple developers to work simultaneously
Lets you roll back to any previous version
And the most important part:
Git works locally on your machine. You don’t even need the internet to use it.
Who Created git and Why?
Git was created in 2005 by Linus Torvalds, the same person who created Linux.
At that time, the Linux kernel project needed a fast, reliable version control system that could:
Handle large codebases
Support thousands of developers
Be distributed and efficient
Existing tools failed to meet these needs, so Git was introduced.
Today, git is the industry standard for version control.
The Confusion between Git vs Github
When I was first introduced to version control, I used to think that Git and Github were the same thing. That confusion is very common, so let’s clear it up properly.
What is Git?
Git is a version control system.
It runs on your local machine and helps you:
Track changes in your code
Create versions(commits)
Go back to older versions
Work with branches
Even without internet, git works perfectly.
Think of Git as:
- A smart system that remembers every meaningful change you make to your code.
What is Github?
Github is a hosting platform for git repositories.
It helps you:
Store your git repositories online
Collaborate with other developers
Share code publicly or privately
Act as a backup for your projects
Think of Github as:
- A cloud locker where your Git-manages code lives and where teams meet. We can also say that github can be a ui to your git.
Why both Matter in Real Teams
In modern development:
Git manages history & changes
Github manages collaboration & sharing
Together, they completely eliminate the pendrive problem.
Git solves problems we faced in the pendrive era:
No more overwritten code
No more guessing who changes what
No more fear of breaking things
With git, we can:
Experiment safety using branches
Collaborate without conflicts
Debug faster using commit history
Git Basic and Core Terminologies
Let’s understand Git language before using the commands.
Repository (Repo)
A repository is a project tracked by Git.
It contains:
Your code
All commit history
Branches and metadata
Commit
A commit is a snapshot of the code at a specific point in time.
Each commit has:
A unique ID(hash)
Author information
A commit message
Commits are like save points in a game.
Branch
A branch is an independent line of development.
It allows us to:
Work on features safely
Fix bugs without affecting main code
By default, Git creates a branch called main or master
Head
HEAD points to your current commit
Whenever we:
Switch Branches
Create a new commit
HEAD moves accordingly.
Git Areas: How Git actually Works
Git works in 3 main areas:
Working Directory → Staging Area → Repository
Working Directory: Where we write the code
Staging Area: Where we prepare changes
Repository: Where commits are stored
This design gives git its power and safety.
Essential Git Commands
git init
Initializes a new git repository
This creates a hidden
.gitfolder that tracks everything.git status
Shows the current state of your repository
We can see:
Modified files, staged files and untracked files
This is the most use git command.
git add
Adds files to staging area.
git add file.jsOr add everything:
git add .git commit
Creates a snapshot of stages changes.
git commit -m “Add login functionality”Good commit messages explain why, not just what.
git log
Shows commit history.
git logWe can see:
Commit ids, Authors and messages

git branch
List branches or creates a new one.
git branchCreate a new branch:
git switch feature-login
git checkout
Switch between branches
git switch feature-logingit merge
Merge one branch into another.
git merge feature-login
A simple Git Workflow

The above diagram is a simple workflow of how exactly git works.
Conclusion
Git might feel overwhelming at first, and that’s okay.
Every developer who uses git today once struggled with:
Conflicts
Commits
Branches
But once it clicks, git becomes invisible it simply protects your work.
If the pendrive era taught us pain, git taught us discipline.
And once we learn git properly, there’s no going back.




