In short
Ever named a file final_v2_REAL_final.html? Git fixes that for good. One command and your folder starts remembering every version you save.
git init turns a normal folder into a Git repository, creating a hidden .git folder that stores the project's full history.

Think of it like this
Opening a new attendance register
Before the register exists, nobody can mark anything. Once the class teacher opens it, every day gets recorded. git init opens that register for your folder. From then on, Git can record each change you choose to save.
Watch it happen
Your very first repo
git init -b main
1/5Git creates the hidden .git folder. Your folder is now a repository, with an empty history.
The big ideas
What you need to know
A hidden .git folder
git init creates a .git folder inside your project. That's where Git keeps your whole history. Delete it and the history is gone.
Three places for your files
The working folder (what you edit), the staging area (what's ready to save) and the repository (saved snapshots).
.gitignore keeps junk out
List folders like node_modules and files like .env in .gitignore so Git never tracks them.
Name your first branch
Use git init -b main so your first branch is called main, which matches GitHub's default.
See it in code
Walk through the code
1mkdir my-portfolio && cd my-portfolio2git init -b main3 4# Tell Git what to skip5echo "node_modules/" >> .gitignore6echo ".env" >> .gitignore7 8git status # see what Git notices9git add .10git commit -m "Initial commit"1/4Make a folder, move into it, and turn it into a Git repository with main as the first branch.
git status is your best friend. Run it whenever you're unsure, it tells you exactly which files are new, changed or staged.
Save yourself the pain
Common mistakes
Oops
Running git init in your home folder by mistake, so Git tracks your whole laptop.
Do this instead
Always cd into the project folder first. If it happened, delete that stray .git folder from home.
Oops
Adding .gitignore after node_modules is already committed.
Do this instead
Add .gitignore first. If it's too late, run git rm -r --cached node_modules and commit.
Your mission
Start tracking a project
Quick check
You accidentally delete the .git folder inside your project. What do you lose?
Go deeper
- 1Run git init in a practice folder and check git status.
- 2Add a .gitignore that excludes node_modules and .env files.
- 3Never run git init inside your home folder by mistake.
Also part of these roadmaps
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.