
The Three-Stage Workflow
Git’s power comes from its three-stage workflow that gives you complete control over what gets committed:
- Modified: Files changed in working directory
- Staged: Files marked for next commit
- Committed: Files permanently stored in Git history
Essential Commands in Action
Creating and Tracking Files:
bash
# Create a new file
echo "# My Awesome Project" > README.md
echo "print('Hello, Git!')" > main.py
# Check what Git sees
git status
# Stage files for commit
git add README.md
git add main.py
# Or stage all files at once
git add .
# Create your first commit
git commit -m "Initial commit: Add README and main script"
Understanding Git Status:
bash
# Detailed status information
git status --long
# Concise status format
git status --short
# See what's staged vs unstaged
git diff # Shows unstaged changes
git diff --staged # Shows staged changes
Viewing Project History
bash
# Basic commit history
git log
# Compact one-line format
git log --oneline
# Visual branch representation
git log --graph --oneline --all
# Show changes in each commit
git log -p
Undoing Changes
Before Staging:
bash
# Discard changes in working directory
git checkout -- filename.txt
# Or using newer syntax
git restore filename.txt
After Staging:
bash
# Unstage a file
git reset HEAD filename.txt
# Or using newer syntax
git restore --staged filename.txt
Hands-On Exercise: Create a small Python calculator project. Practice the add-commit cycle, view history, and experiment with undoing changes.
You Might Also Like
🛠️ Recommended Tools for Developers & Tech Pros
Save time, boost productivity, and work smarter with these AI-powered tools I personally use and recommend:
1️⃣ CopyOwl.ai – Research & Write Smarter
Write fully referenced reports, essays, or blogs in one click.
✅ 97% satisfaction • ✅ 10+ hrs saved/week • ✅ Academic citations
2️⃣ LoopCV.pro – Build a Job-Winning Resume
Create beautiful, ATS-friendly resumes in seconds — perfect for tech roles.
✅ One-click templates • ✅ PDF/DOCX export • ✅ Interview-boosting design
3️⃣ Speechify – Listen to Any Text
Turn articles, docs, or PDFs into natural-sounding audio — even while coding.
✅ 1,000+ voices • ✅ Works on all platforms • ✅ Used by 50M+ people