The Core Workflow
Git revolves around a simple 3-step workflow: Modify → Stage → Commit.
1. Modify
Create or edit files
2. Stage
Select changes to save
3. Commit
Save snapshot permanently
1. Initialize (git init)
Turns a regular folder into a Git repository. This creates a hidden .git folder that tracks every change you make.
mkdir my-project
cd my-project
git initPro Tip
You only run this once per project. Do not run it inside a folder that is already a repo!
2. Check Status (git status)
Your best friend. Tells you exactly what's going on: which files are modified, staged, or untracked.
git statusOn branch main
Untracked files:
index.html
Insight
Run this command whenever you are confused. It's safe and never changes anything.
3. Stage Changes (git add)
Moves files from "Modified" to "Staged". Think of this as putting items into a box before sealing it.
# Stage a specific file
git add index.html
# Stage ALL changed files (Common)
git add .Why Stage?
Staging lets you group related changes together. You might edit 10 files but only want to commit 3 of them.
4. Save Snapshot (git commit)
Seals the box. Saves a permanent snapshot of the staged files with a message describing what you did.
git commit -m "Create homepage layout"Writing Good Commit Messages:
✅ Good
"Add login form validation"
❌ Bad
"Fixed stuff"
Best Practice
Commit often! Small, focused commits are easier to understand and fix than massive ones. This is called Atomic Commits.
Pro Shortcut
Skip the staging step for files Git already knows about:
git commit -am "Message"5. View History (git log)
See a list of all commits in the repository's history.
git log
# One-line summary (Cleaner)
git log --onelineInteractive Practice
Try the workflow yourself! We've initialized a repo for you.
Loading terminal...
Mission 1:
Create a file called style.css and check status.
touch style.css && git statusMission 2:
Stage and commit the file.
git add . && git commit -m "Add styles"