Git and GitHub

Track every change to your code with Git, and store and share it on GitHub.

Module 7: Ship it · Lesson 23 of 25 · 16 min read · Free

Git keeps a history of your project: every saved snapshot (commit), who changed what, and the ability to go back. GitHub stores your Git projects online — your backup, your collaboration space and your public portfolio. Employers look at GitHub profiles.

From your editor to a live site

Set up (once)

  1. Install Git from git-scm.com (on Mac it may already be installed).
  2. Create a free account at github.com.
  3. Tell Git who you are, in a terminal (VS Code: Terminal → New Terminal):
git config --global user.name "Chiamaka Obi"
git config --global user.email "chiamaka@example.com"

The everyday cycle

git init                         # once, inside your project folder
git add .                        # stage all changed files
git commit -m "Add product grid" # save a snapshot with a message

Then, after creating an empty repository on GitHub (click New, name it e.g. mama-nkechi-shop):

git remote add origin https://github.com/your-username/mama-nkechi-shop.git
git branch -M main
git push -u origin main          # upload

From then on, the cycle is just add → commit → push.

Doing it without the terminal

VS Code's Source Control panel (the branch icon) does the same with buttons: type a message, click ✓ Commit, then Sync / Publish Branch. It's a fine way to start; learn the commands as you go — you'll see them in every job.

Good habits

  • Commit small and often, with messages that say what changed: “Fix cart total rounding”, not “update”.
  • Never commit passwords, API keys or private data. A .gitignore file lists files Git should skip (node_modules/, .env).
  • Write a README.md for each project: what it is, a screenshot, how to run it, a link to the live site.

Check yourself

Answer in your head first, then open each question to see the answer and why.

  1. What does git commit do?

    • A Saves a snapshot of your staged changes with a message
    • B Uploads to GitHub
    • C Deletes old files
    • D Opens VS Code
    Show the answer

    A) Saves a snapshot of your staged changes with a message — Commit records history locally; push uploads it.

  2. Which command uploads your commits to GitHub?

    • A git push
    • B git add
    • C git init
    • D git status
    Show the answer

    A) git push — push sends local commits to the remote repository.

  3. What should never be committed to a public repository?

    • A Passwords and API keys
    • B index.html
    • C style.css
    • D A README
    Show the answer

    A) Passwords and API keys — Anything pushed publicly can be read by anyone.

More free lessons: What front-end developers do · Set up VS Code, Chrome and Live Server · Text, links and images · Selectors, colours and fonts · Mobile-first design and media queries · Variables, data types and operators · The DOM: find and change page elements