Lesson 2 of 4

Git & GitHub

A time machine for your project, plus a safe home for it in the cloud.

Why bother with version control?

Imagine editing your site, breaking something, and having no way back. Or emailing yourself site-final-v2-REALLY-final.zip. Git fixes both problems. It takes snapshots of your project so you can:

Git vs GitHub — what's the difference?

Git

The tool

A program on your computer that takes the snapshots. It works entirely offline.

GitHub

The website

A place on the internet that stores your Git snapshots so they're backed up and shareable. Think "cloud storage for code".

Analogy: Git is the camera; GitHub is the online photo album you upload the pictures to.

One-time setup

  1. Create a free account at github.com.
  2. Install Git from git-scm.com/downloads (Mac users often already have it).
  3. Tell Git who you are — run these once in your terminal:
terminal
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

The everyday loop

Inside your website folder, the core rhythm is just a few commands. Here's the whole cycle, start to finish:

terminal — inside your project folder
# 1. Turn this folder into a Git project (only once, ever)
git init

# 2. Check what has changed at any time
git status

# 3. Stage the files you want to snapshot ("." means everything)
git add .

# 4. Save the snapshot with a short message describing it
git commit -m "Add home page and styling"
Key words, decoded:
  • Repository (or "repo") — your project folder, tracked by Git.
  • Commit — one saved snapshot, with a message. Your history is a list of commits.
  • Branch — a parallel line of work. The main one is usually called main.
  • Push — upload your commits to GitHub. Pull — download changes from GitHub.

Push your project to GitHub

  1. On GitHub, click New repository, give it a name (e.g. my-website), and create it. Leave it empty — don't add a README yet.
  2. GitHub shows you a URL like https://github.com/you/my-website.git. Connect your local folder to it and push:
terminal
# Point your local repo at the GitHub one ("origin" is just a nickname)
git remote add origin https://github.com/you/my-website.git

# Name your main branch and upload it
git branch -M main
git push -u origin main

Refresh your GitHub repo page — your files are now safely in the cloud. 🎉 From now on, after each commit, just run git push to sync.

Good commit messages matter. Write them like a short instruction: "Add contact form", "Fix mobile menu", "Change accent color to blue". Future-you will thank present-you.
Never commit secrets. Passwords, API keys, and tokens should not go into a repo. Put their filenames in a .gitignore file and Git will skip them.

Typing every file by hand is a lot. In the next lesson, meet Claude Code — an AI that can write and edit these files (and even run the Git commands) with you.