Git for Beginners:
Before Git, developers managed code by making copies of files and folders.
There was no clear history of changes, and working in a group was difficult.
Code was often lost or overwritten.
Before Git, developers working on large projects like Linux faced many problems:
code changes were hard to track
working with many developers was slow
existing tools were either paid, slow, or unreliable
HOW GIT CAME INTO PLACE:
While working on the Linux project, Linus Torvalds needed a better way to track code changes and manage many developers working together.
So, in 2005, he created Git as a new version control system for the Linux kernel.
What is Git?
Git is a tool that helps you save your code properly.
Git works like a tracker. It records what changes we make in our code and saves them safely.
It is also used when working in a group, so everyone’s code stays safe and organized.
Why Git is Used
Without Git, developers face problems like:
code getting lost
mistakes that cannot be undone
confusion between old and new files
Git helps to:
keep a history of your code
undo mistakes
work safely on projects
Even beginners and solo developers use Git.
Basic Git Terms:
Repository (Repo)
A repository is just a project folder where Git is active.
Example:
Your project folder becomes a Git repo.
Commit
A commit means saving your work with a message.
Example:
“I finished gaming page”
Each commit is a checkpoint.
Branch
A branch is a separate line of work.
mainbranch → main working codeother branch → try new things safely
Beginners can start with just main.
HEAD
HEAD means where you are right now in the project.
You don’t need to worry much about it in the beginning.
Basic Git Commands (Beginner Level)
git init
Starts Git in a folder.
git init
➡ Git starts tracking your project.
git status
Shows what is happening in your project.
git status
➡ Shows changed files and new files.
git add
Tells Git which files to save.
git add .
➡ Selects all files for saving.
git commit
Saves your work.
git commit -m "My first commit"
➡ Stores your changes with a message.
git log
Shows all saved history.
git log
➡ Shows previous commits.
Simple Git Workflow (Step by Step)
1️⃣ Create a folder
2️⃣ Start Git
3️⃣ Write code
4️⃣ Add files
5️⃣ Commit (save)
Example:
git init
git add .
git commit -m "First save"
That’s it.
You just used Git successfully
Git Working Directory → Staging Area → Repository
Git works in three simple steps:
1️⃣ Working Directory
This is where you write and edit your code.
Create files
Edit files
Delete files
➡ Nothing is saved by Git yet.
2️⃣ Staging Area
The staging area is like a waiting room.
You choose which files you want to save
Git prepares them for commit
Command used:
git add .
➡ “I want to include these changes.”
3️⃣ Repository
The repository is where Git permanently saves your work.
Command used:
git commit -m "Saved my work"
➡ Your changes are now stored safely.
Simple Flow Diagram
Working Directory → Staging Area → Repository
Local Repository Structure (Easy Overview)
When Git is initialized, it creates a hidden folder called .git.
Example:
my-project/
├── app.py
├── README.md
└── .git/
Your files → normal project files
.gitfolder → stores all Git data
👉 You usually never touch the .git folder.
Commit History Flow:
Each commit is like a save point.
Commit 1 → Commit 2 → Commit 3 (HEAD)
Each commit stores changes
HEAD shows the current commit
You can move back to older commits if needed