Git for Beginners
Source: Dev.to
What is Git?
Git is a tool that helps you save, track, and manage changes in your code.
In simple words: Git remembers every version of your project so you can move forward or go back anytime.
Think of Git like:
- a save button with history
- a backup for your code
- a tool that lets many people work together safely
Why Git is Used?
Git makes a developer’s life easier.
- You can undo mistakes
- You can see who changed what
- You can work on new features without breaking existing code
- You can collaborate with a team smoothly
That’s why almost every company uses Git.
Core Git Concepts (Very Simple)
Repository (Repo)
A repository is just your project folder that Git is tracking. Inside it, Git stores all change history.
Commit
A commit is a saved version of your code. Think of it as: “I like the current state of my project. Save it.”
Example commit message:
Added homepage UI
Branch
A branch is a separate copy of your code to work safely.
main→ stable codefeature-login→ new work
Branches let you experiment without fear.
HEAD
HEAD tells Git where you are right now. It points to the current commit you are working on.
Git’s 3 Important Areas
Working Directory → Staging Area → Repository
- Working Directory: where you edit files
- Staging Area: where you prepare files
- Repository: where commits are stored
Common Git Commands (You’ll Use These Daily)
Start Git in a Project
git init
Check What’s Changed
git status
Add Files to Git
git add index.html
git add .
Save Your Changes
git commit -m "Initial setup"
See Past Saves
git log --oneline
A Real Developer Workflow (From Scratch)
mkdir my-project
cd my-project
git init
Create a file → edit it → then:
git add .
git commit -m "Add first version"
Make changes → repeat the same steps. This is exactly how developers use Git daily.
How Git History Looks
Linear history
Commit A → Commit B → Commit C (HEAD)
With branches
main ── A ── B
\
C ── D (feature)
Project Structure (Simple View)
Project Folder
├── Your files (working directory)
└── .git (Git history)
Final Thoughts
Git is not hard — it’s just new. If you understand:
- what a commit is
- how to add and save changes
- the basic workflow
you already know 80 % of Git. Practice a little every day, and Git will feel natural very quickly.
Happy coding 🚀