Git is a superpower for developers. This guide teaches it step-by-step, with plain English, real examples, and zero assumed knowledge.
Imagine you're writing a big essay. You keep saving it as essay_v1.docx, then essay_v2.docx, then essay_FINAL.docx, then essay_FINAL_REAL.docx...
Git solves this mess. It's a tool that tracks every change you make to your code — automatically, safely, and without creating a million files.
Git is like a time machine + camera for your code. Every time you say "save this moment", Git takes a snapshot. You can always go back to any past snapshot — even if you accidentally delete everything.
Git is the tool on your computer. GitHub is a website that stores your Git projects online (like Google Drive for code). You need Git to use GitHub.
Before using Git, you tell it who you are. This info gets attached to every change you make — like a signature.
The --global flag means these settings apply to every Git project on your computer.
A commit is like taking a photo of your code at a specific moment. Let's understand how files move through Git before you start committing.
Think of staging as packing a box before shipping it. You choose which items go in the box (git add), then seal and send it (git commit). You don't have to pack everything — just what's ready.
git status is your best friend — run it constantly to see what's happening:Git can see these files exist, but it's not watching them yet. You haven't told Git to care about them.
❌ Bad: "fix stuff" ✅ Good: "Fix login button not working on mobile"
A branch is like a parallel universe for your code. You can experiment, add features, or fix bugs — completely separately from your main code. If it works, merge it in. If it doesn't, just delete the branch.
Imagine you're writing a book. You want to try a different ending. You photocopy the book, write the new ending in the copy, and if you like it, replace the original ending. The original is always safe. That copy is a branch.
* shows your current branch:GitHub is where your Git project lives online. It's your backup, your portfolio, and how you collaborate with others. The most important commands here are push (upload) and pull (download).
At the start of your day: git pull. After finishing work: git add . → git commit -m "..." → git push. That's 90% of what you'll do every day.
Everyone makes mistakes. The good news? Git makes most mistakes fixable. Here are the situations beginners hit most often:
As long as you've committed it, Git has it. Even if you delete files, run git reflog and you can almost always get everything back.
This is one of the few Git commands that can't be undone. Only use it if you're sure you want to discard those changes.