What's Git Anyway?
Git = Time machine for your code. Every change gets saved. You can always go back.
GitHub = Cloud storage for your Git projects. Like Google Drive, but designed for code.
That's really all you need to know to get started.
Step 1: Install Git Bash
Windows
- Go to git-scm.com
- Download and run the installer
- Keep the default settings and click "Next" through everything
Mac
brew install git
Linux
sudo apt-get install git # Ubuntu/Debian
sudo dnf install git # Fedora
Verify It Worked
git --version
See a version number? You're good! β
Step 2: Connect to GitHub
Create Your Account
Head to github.com and sign up. Verify your email.
Tell Git Who You Are
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Important: Use the same email as your GitHub account!
Set Up SSH Keys (The Better Way)
Instead of typing passwords constantly, use SSH:
# Generate your key
ssh-keygen -t ed25519 -C "your@email.com"
# Press Enter 3 times (default location, no password)
# Display your key
cat ~/.ssh/id_ed25519.pub
Copy everything that appears (starts with ssh-ed25519).
Now on GitHub:
- Settings β SSH and GPG keys
- Click "New SSH key"
- Paste your key and save
Test the Connection
ssh -T git@github.com
See "Hi username!"? Perfect! You're connected. π
Step 3: Why Version Control Matters
Without Git, you end up with:
project.zip
project_final.zip
project_final_ACTUALLY_FINAL.zip
With Git:
- One project folder
- Complete history of all changes
- Ability to jump back to any previous version
- Safe experimentation without fear
That's version control. It keeps your project history organized and accessible.
Step 4: Track Your First Project
Start a New Project
mkdir my-project
cd my-project
git init
Git is now watching this folder!
Create a File
Make a file called app.py:
print("Hello, Git!")
See What Changed
git status
Git says: "I see app.py but I'm not tracking it yet."
Track the Changes
git add .
This "stages" your changes - telling Git you want to save them.
Save a Snapshot (Commit)
git commit -m "Create initial app"
You just made your first commit! It's a saved point you can always return to.
Good commit messages:
- "Add login form"
- "Fix mobile navigation bug"
- "Update installation instructions"
Bad commit messages:
- "stuff"
- "changes"
- "idk"
View Your History
git log --oneline
There's your commit with its unique ID!
Step 5: Push to GitHub
Create a Repo on GitHub
- Click the + icon β New repository
- Name it
my-project - Keep it Public (or choose Private)
- Don't initialize with README
- Click "Create repository"
Link and Upload
git remote add origin git@github.com:YOUR-USERNAME/my-project.git
git branch -M main
git push -u origin main
Refresh GitHub. Your code is online! π
The Regular Workflow
From now on, it's just:
# Make changes to your files
git add .
git commit -m "Describe what you changed"
git push
Three commands. That's your daily routine.
Step 6: Pull Changes
Someone else updated the project? You edited on GitHub? Working from another computer?
git pull
Done. You now have the latest version.
Pro tip: Always git pull before you start working!
When Conflicts Happen
Sometimes you and someone else edit the same line. Git shows:
<<<<<<< HEAD
print("Your version")
=======
print("Their version")
>>>>>>> origin/main
Fix it:
- Choose which version to keep (or combine them)
- Delete those marker lines (
<<<<<<<,=======,>>>>>>>) - Save, then:
git add .
git commit -m "Resolve conflict"
git push
Conflicts are normal. Don't stress!
Command Cheat Sheet
The ones you'll actually use:
| Command | What it does |
|---|---|
git status |
"What changed?" |
git add . |
"Track all changes" |
git commit -m "..." |
"Save snapshot" |
git push |
"Upload to GitHub" |
git pull |
"Download updates" |
git log --oneline |
"Show history" |
Undo Mistakes
| Command | What it does |
|---|---|
git restore <file> |
Undo changes to a file |
git restore --staged <file> |
Unstage a file |
git reset HEAD~1 |
Undo last commit |
Common Mistakes (And Fixes)
β Forgot to commit before pushing
git add .
git commit -m "Add missing commit"
git push
β Didn't pull first
git pull
# Fix any conflicts if needed
git push
β Committed passwords
Delete them, then:
echo "secrets.txt" >> .gitignore
git add .gitignore
git commit -m "Ignore sensitive files"
Why This Matters
- Safety: Never lose work again
- Confidence: Experiment without fear of breaking things
- Collaboration: Work with teams smoothly
- Portfolio: Show your projects on GitHub
- Career: Every dev job uses Git
What's Next?
You know enough to start using Git daily. Just apply it to everything you build:
- Personal projects
- School assignments
- Practice exercises
The best way to learn? Use it!
Wrapping Up
You now know how to install Git, connect it to GitHub, track your changes and collaborate with others. These are the fundamentals that every developer uses daily.
The key is to start small. Pick a project - any project - and start committing. Make mistakes. Break things. That's how you learn. Git has your back because you can always go back to a working version.
Remember: the best developers aren't the ones who never make mistakes. They're the ones who know how to recover from them. And with Git, recovery is always just one command away.
Now stop reading and start coding. Your first commit is waiting! π»
What's the first project you're going to put on GitHub? Or if you've already started using Git, what was your biggest "aha!" moment? Share in the comments below - I'd love to hear your Git journey!
Top comments (0)