Git for Beginners: A Simple Guide to Version Control

Search for a command to run...

No comments yet. Be the first to comment.
DNS Explained with dig: From Root Servers to Google.com When you type google.com into your browser, a surprising amount of distributed system machinery spins up behind the scenes.At the heart of it all is DNS — the Domain Name System. This article br...

Before Git, GitHub, and modern collaboration tools, software development looked very different — and honestly, a bit chaotic. If you’ve ever seen folders named final, final_v2, or latest_final_REAL, then you already understand why version control exi...

Most developers learn Git by memorizing commands like git add and git commit.But Git becomes much easier once you understand what’s happening under the hood. In this article, we’ll explore: What the .git folder really is How Git stores data interna...

My Tech Diary
4 posts
If you’re starting your developer journey, one of the first tools you’ll hear about is Git.
Git helps you track changes in your code, collaborate with others, and safely experiment without fear of losing work.
This article explains what Git is, why it’s used, and how to use it step by step, even if you’re completely new.
Git is a distributed version control system.
In simple terms:
It tracks changes in your files
It lets you save versions of your project
It allows multiple developers to work on the same code without conflicts
Unlike older systems, Git gives every developer a full copy of the project history on their own machine.
Git is used because it helps developers:
✅ Track who changed what and when
✅ Roll back to earlier versions if something breaks
✅ Work on features without affecting the main code
✅ Collaborate efficiently with teams
✅ Maintain a clean and reliable project history
Whether you’re working solo or in a team, Git is essential.
Before running commands, let’s understand some key Git concepts.
A repository is a project folder that Git is tracking.
It contains:
Your project files
A hidden .git directory that stores history and metadata
A commit is a snapshot of your project at a specific point in time.
Think of it like:
“Save game” 🎮 for your code
Each commit has:
A unique ID (hash)
A message describing the change
A branch lets you work on features independently.
main (or master) → stable code
feature branches → experiments or new features
HEAD is a pointer to the current commit you’re working on.
Usually, it points to the latest commit on the current branch.

Git works in three main areas:
Working Directory – where you edit files
Staging Area – where you prepare files for commit
Repository – where commits are permanently stored
Let’s see the most important Git commands used daily.
git initCreates a new Git repository.
git init
Use this inside your project folder.
git statusShows the current state of your files.
git status
It tells you:
Which files are modified
Which files are staged
What’s not tracked yet
git addMoves changes to the staging area.
git add file.txt
Or add everything:
git add .
git commitSaves staged changes to the repository.
git commit -m "Add initial project files"
💡 Always write clear commit messages.
git logShows the commit history.
git log
You’ll see:
Commit IDs
Author
Date
Commit message

git branchLists or creates branches.
git branch
Create a new branch:
git branch feature-login
git checkoutSwitch between branches.
git checkout feature-login
(Modern alternative: git switch)


Let’s walk through a basic developer workflow.
mkdir my-project
cd my-project
git init
Create a file:
echo "Hello Git" > readme.txt
Check status:
git status
Stage the file:
git add readme.txt
Commit:
git commit -m "Add readme file"
Check history:
git log
🎉 You’ve successfully used Git!