1. What is Git really? (Super simple analogy)
Imagine you’re writing a very important story (a novel).
- Without Git → You make copies: story_v1.docx story_v2_final.docx story_v2_final_really.docx story_v2_final_23-01-2026.docx → Chaos after 2 weeks
- With Git → You have one single story file, but Git secretly keeps perfect snapshots (called commits) every time you say “this part is good now”.
You can:
- Go back to any previous version in 2 seconds
- See exactly what changed between versions
- Have multiple people work on the same story without overwriting each other
- Try risky ideas safely in a separate room (branch) and throw them away if bad
Git = time machine + safety net + team collaboration tool for files (mostly code).
Git ≠ GitHub Git = the tool on your computer GitHub = popular online storage + collaboration website for Git repositories
2. First things first – Installation (2026 edition)
Open your terminal / command prompt / PowerShell:
Check if Git is already installed:
|
0 1 2 3 4 5 6 |
git --version |
If you see something like git version 2.4x.x, great! Skip to step 3.
Otherwise:
- Windows → https://git-scm.com/download/win → install → choose Use Git from Git Bash and Command Prompt
- macOS → brew install git (if you have Homebrew) or download from site
- Linux (Ubuntu) → sudo apt update && sudo apt install git
After install, set your identity (very important – appears in commits):
|
0 1 2 3 4 5 6 7 |
git config --global user.name "Webliance" git config --global user.email "your-real-email@gmail.com" |
Check:
|
0 1 2 3 4 5 6 |
git config --global --list |
3. Our First Project – Hands-on from scratch
Let’s create a tiny project.
- Create folder and go inside
|
0 1 2 3 4 5 6 7 |
mkdir my-todo-app cd my-todo-app |
- Tell Git: “Start tracking this folder”
|
0 1 2 3 4 5 6 |
git init |
You’ll see: Initialized empty Git repository in …/.git/
Now there’s a hidden .git folder — that’s your time machine.
- Create first file
Create index.html (you can use VS Code, Notepad, whatever)
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<!DOCTYPE html> <html> <head> <title>My Todo App</title> </head> <body> <h1>Todo List</h1> <ul> <li>Learn Git</li> </ul> </body> </html> |
- Tell Git: “Hey, watch this file”
|
0 1 2 3 4 5 6 |
git status |
You’ll see red: index.html is untracked
Now add it to staging area (index):
|
0 1 2 3 4 5 6 7 |
git add index.html # or git add . ← adds everything |
git status now shows green.
Staging = “I want to include these changes in my next snapshot”
- Take first snapshot (commit)
|
0 1 2 3 4 5 6 |
git commit -m "Initial todo list structure" |
You’ll see something like:
|
0 1 2 3 4 5 6 7 8 |
[main (root-commit) abc1234] Initial todo list structure 1 file changed, 9 insertions(+) create mode 100644 index.html |
Congratulations! 🎉 You just made your first commit.
4. Everyday Workflow – The sacred 4 steps
You work → stage → commit → (later) push
Let’s make changes:
Add one more todo in index.html:
|
0 1 2 3 4 5 6 7 |
<li>Drink water</li> <li>Finish Git tutorial</li> |
Now:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 |
# See what changed git diff # Stage git add index.html # Commit with good message git commit -m "Add two more realistic tasks" |
Do few more changes:
- Change title to <h1>My Awesome Todo List 2026</h1>
- Add one more <li>Walk 30 mins</li>
|
0 1 2 3 4 5 6 7 |
git add . git commit -m "Improve title and add daily walk reminder" |
Now check history:
|
0 1 2 3 4 5 6 |
git log --oneline |
You should see something like:
|
0 1 2 3 4 5 6 7 8 |
def5678 Improve title and add daily walk reminder abc9999 Add two more realistic tasks abc1234 Initial todo list structure |
Beautiful timeline!
5. Undo / Time Travel – Most useful beginner skills
Oops! I messed up the title!
See last commit:
|
0 1 2 3 4 5 6 |
git show |
Go back one version:
|
0 1 2 3 4 5 6 7 8 |
git checkout HEAD~1 # temporarily go back # or git checkout abc9999 # specific commit |
Want to permanently undo last commit but keep changes in working directory?
|
0 1 2 3 4 5 6 |
git reset --soft HEAD~1 |
Want to completely throw away last commit?
|
0 1 2 3 4 5 6 7 |
git reset --hard HEAD~1 # Careful – cannot recover easily! |
Made mess in working directory (not committed yet)?
|
0 1 2 3 4 5 6 7 |
git restore index.html # one file git restore . # everything |
6. Branches – Why they are awesome
Main = stable version (usually called main now, not master)
You want to try new feature without breaking main.
|
0 1 2 3 4 5 6 7 8 9 |
git branch feature/dark-mode git checkout feature/dark-mode # or better one-liner: git checkout -b feature/dark-mode |
Now you’re on new branch. Change index.html – add dark mode class or whatever.
|
0 1 2 3 4 5 6 |
<body class="dark"> |
Commit:
|
0 1 2 3 4 5 6 7 |
git add . git commit -m "Add basic dark mode class" |
Switch back:
|
0 1 2 3 4 5 6 |
git checkout main |
→ Dark mode disappeared! (safe)
Like it? Merge:
|
0 1 2 3 4 5 6 7 |
git checkout main git merge feature/dark-mode |
Don’t like? Delete branch:
|
0 1 2 3 4 5 6 |
git branch -d feature/dark-mode |
7. Connect to GitHub (remote)
- Go to github.com → New repository Name: my-todo-app Public / Private → create (do not check “Add README”)
- Link your local repo:
|
0 1 2 3 4 5 6 |
git remote add origin https://github.com/your-username/my-todo-app.git |
- Send your work:
|
0 1 2 3 4 5 6 7 |
git branch -M main git push -u origin main |
Now your code lives online too!
From now on just:
|
0 1 2 3 4 5 6 |
git push |
Quick Summary Table – Your First-day Cheat Sheet
| Action | Command | What it does |
|---|---|---|
| Start tracking folder | git init | Creates .git folder |
| See what’s happening | git status | Most used command! |
| Add file to staging | git add file.txt / git add . | Prepare for commit |
| Save snapshot | git commit -m “message” | Creates version |
| See history | git log –oneline | Beautiful list |
| Create & switch branch | git checkout -b name | Safe experiment space |
| Merge branch | git checkout main git merge name | Combine changes |
| Send to GitHub | git push | After first push -u |
| Get latest from GitHub | git pull | Very important when collaborating |
Practice this flow 5–10 times on a dummy folder and you’ll never forget it.
Any command confusing? Which part you want to go deeper — branching, resolving conflicts, .gitignore, pull requests, or something else?
Just tell me — we’ll continue the class! 🚀
