DEV Community

Mariam Turnesh
Mariam Turnesh

Posted on • Edited on

Git & GitHub: Your Quick Start Guide

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

  1. Go to git-scm.com
  2. Download and run the installer
  3. Keep the default settings and click "Next" through everything

Mac

brew install git
Enter fullscreen mode Exit fullscreen mode

Linux

sudo apt-get install git  # Ubuntu/Debian
sudo dnf install git      # Fedora
Enter fullscreen mode Exit fullscreen mode

Verify It Worked

git --version
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Copy everything that appears (starts with ssh-ed25519).

Now on GitHub:

  1. Settings β†’ SSH and GPG keys
  2. Click "New SSH key"
  3. Paste your key and save

Test the Connection

ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Git is now watching this folder!

Create a File

Make a file called app.py:

print("Hello, Git!")
Enter fullscreen mode Exit fullscreen mode

See What Changed

git status
Enter fullscreen mode Exit fullscreen mode

Git says: "I see app.py but I'm not tracking it yet."

Track the Changes

git add .
Enter fullscreen mode Exit fullscreen mode

This "stages" your changes - telling Git you want to save them.

Save a Snapshot (Commit)

git commit -m "Create initial app"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

There's your commit with its unique ID!


Step 5: Push to GitHub

Create a Repo on GitHub

  1. Click the + icon β†’ New repository
  2. Name it my-project
  3. Keep it Public (or choose Private)
  4. Don't initialize with README
  5. 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Fix it:

  1. Choose which version to keep (or combine them)
  2. Delete those marker lines (<<<<<<<, =======, >>>>>>>)
  3. Save, then:
git add .
git commit -m "Resolve conflict"
git push
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

❌ Didn't pull first

git pull
# Fix any conflicts if needed
git push
Enter fullscreen mode Exit fullscreen mode

❌ Committed passwords

Delete them, then:

echo "secrets.txt" >> .gitignore
git add .gitignore
git commit -m "Ignore sensitive files"
Enter fullscreen mode Exit fullscreen mode

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)