CurriculumWeek 04 · CapstoneBuild block + GitHub
Lesson 04.02 · ~20 min read

Build block + GitHub

Just enough git to publish: init, add, commit, push. Then a real README in markdown.

By Kelvin AmoabaUpdated May 12, 2026Prerequisite: 04.01

What we're doing today

By the end of this session, you will have a small Python file living on the internet, at a real link you can send to anyone. You will type a few commands in your terminal, click a few buttons on a website, and your code will be online. That is the whole goal. If you have never done any of this before, today is the day it stops being mysterious.

The first time you do it, it will feel like you are reciting a magic spell you do not understand. That is fine. You only need to understand it well enough to use it. Understanding deepens later.

The two words you need before we start

Two words come up over and over today. Let me settle them now.

Git is a tool that takes a snapshot of your project whenever you tell it to, so you can go back if you break something. Like saving your essay as final-v1.docx, final-v2.docx, final-v3-actually-final.docx, except git does the versioning properly for you. It lives on your laptop and works even when the internet is off.

GitHub is a website that stores your git project online, so other people — or another laptop of yours — can see it. Think of it like putting your work in a shared Dropbox folder so you can pull it down on another machine. Git is the tool. GitHub is the website. They are not the same thing. They just work together so often that people mix them up.

Installing git

You do this once per laptop. Open your terminal — Terminal on Mac, Command Prompt or PowerShell on Windows.

On Mac, run xcode-select --install and click Install in the window that pops up. On Windows, download the installer from git-scm.com and click Next until it finishes. On Linux (Ubuntu and similar), run sudo apt install git.

Check it worked:

git --version

If you see a version number, git is installed. If you see "command not found," shout in the channel and we will pair on it.

Telling git who you are

Git wants to write your name and email next to every snapshot you save, so anyone reading the history later knows who made the change. You tell it once and never again.

git config --global user.name "Your Full Name"
git config --global user.email "you@example.com"

Use your real name. Use the same email you will use to sign up for GitHub in a minute. There is no output when these commands run — that means it worked. Silence is success in the terminal.

A project folder to play with

Let's make a tiny project to work on. In your terminal:

mkdir hello-git
cd hello-git

mkdir makes a folder. cd walks into it. Now open the hello-git folder in your editor, create a file called hello.py, and put one line in it:

print("Hello from my first repo.")

Save it. We will put this file on the internet by the end of the session.

Telling git to watch this folder

Right now, the folder is just a folder. Git does not know it exists. We have to point git at it.

git init

That command turns this folder into a repository — which is just a fancy word for "a project folder that git is tracking." From now on, every change you save inside hello-git can be snapshotted by git. People shorten "repository" to repo in conversation. Same thing.

You will see a message about an "initialized empty repository." That is git saying, "Okay, I am watching this folder now."

Seeing what git sees

Any time you want to know what git is thinking, ask it:

git status

Run that now. You will see something like:

On branch main
 
No commits yet
 
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        hello.py

Read that slowly. Git is telling you: "I can see hello.py, but I am not tracking it yet. You have to tell me to." This is the most useful command in git. When you are confused, run git status and let it talk to you.

Quick word on "branch main" in that output — a branch is a separate line of changes you can work on without disturbing the main one. For this whole course you will only ever use the one called main. Do not worry about it beyond that.

Saving your first snapshot

Saving a snapshot in git is two steps. This trips up everyone the first time, so read it twice.

git add hello.py
git commit -m "Add hello.py"
  • git add hello.py says: "Put this file into the box I am about to seal." You are choosing what goes into the snapshot. If you had three files and only wanted to snapshot one, this is where you would pick.
  • git commit -m "Add hello.py" says: "Seal the box now, and write this message on the side." A commit is one sealed snapshot with a message attached. The -m is short for "message."

The message in quotes is for future-you. Write a short sentence in plain English about what changed. "Add hello.py" is fine. "Fix the bug where input crashed on empty strings" is great. "asdf" is what you write at 2am when you are tired, and you will regret it next week when you cannot find anything.

Run git status again. It should now say "nothing to commit, working tree clean." That means everything you have changed is safely snapshotted.

If you have many files and you want to add all of them at once, you can write git add . — the dot means "everything in this folder." Useful, but be careful: it adds every file, including ones you maybe did not mean to.

Making a GitHub account and a repo

Now we move the snapshot onto the internet. Go to github.com and sign up. Use the same email you put in git config. Use your real name as the username if you can — this is the link you will share.

Once you are in, click the + in the top right, then New repository. Name it hello-git, leave it Public, and do not tick "Add a README file" — we want it empty to match your laptop. Click Create repository.

GitHub now shows you a page with command blocks. Leave that tab open.

Connecting your folder to GitHub

Your folder on your laptop and the empty repo on GitHub do not know about each other yet. You connect them with one command:

git remote add origin https://github.com/YOUR-USERNAME/hello-git.git

Replace YOUR-USERNAME with your GitHub username. That URL is on the page GitHub just showed you — copy it from there to be safe.

What that command does: it tells your local git, "There is a copy of this project on GitHub at this URL. From now on, call it origin." The word origin is just a nickname. You will see it again in the next command.

Pushing your snapshot up

Pushing means sending your saves up to GitHub. One command:

git push -u origin main

That says: "Push my commits to the remote called origin, on the branch called main. And remember this setup so I do not have to type it again next time."

GitHub may ask you to log in. On Mac, a browser window usually pops up. On Windows, it may ask for a personal access token instead of your password — GitHub has a help page for creating one, and we will pair on it in the channel if you get stuck.

Once it finishes, refresh your repo page on GitHub. hello.py is there. Click it. Your code is on the internet. Send the link to your mother.

The everyday loop

You will spend the rest of this course in the same short rhythm:

# you edit some files
 
git status              # what changed?
git add hello.py        # stage the file(s) you changed
git commit -m "Make the greeting friendlier"
git push                # send it to GitHub

Edit. Add. Commit. Push. After the first git push -u origin main, you can just type git push from then on — git remembers.

A good habit: commit when you finish something small that works. Three to five commits a day is normal. If your laptop dies tonight, you only lose what you have not pushed.

The .gitignore file

There are files you never want on GitHub — passwords, API keys, junk files your editor creates. You list them in a file called .gitignore in your project folder, one per line, and git pretends they do not exist. We will set one up properly next session. For now, just know what it is.

Downloading someone else's repo

Last quick one. If you ever want a copy of someone else's project (or your own, on a different laptop), you clone it:

git clone https://github.com/SOMEONE/their-repo.git

That downloads the whole thing into a new folder. You do not need this today, but you will use it before the term is over.

Your exercise

Do the whole loop from scratch, on your own. In a new folder:

  1. Create a file called Hello.py with one print(...) line that greets you by name.
  2. Run git init, git add Hello.py, and git commit -m "Add Hello.py".
  3. Make a new repo on GitHub called hello-from-me.
  4. Connect it with git remote add origin ... and push with git push -u origin main.
  5. Open the repo page on GitHub and check Hello.py is there.

When it works, paste the link in the channel.

Common slip-ups

  • Forgetting to commit before you push. A push only sends commits. If you git add a file but never git commit, there is nothing to push. Run git status — if it does not say "nothing to commit, working tree clean," you have work to seal up.
  • Wrong remote URL. If git push complains about not finding the repository, your origin URL is probably wrong. Check it with git remote -v. If the URL is wrong, fix it with git remote set-url origin https://github.com/YOUR-USERNAME/YOUR-REPO.git.
  • The branch is main, not master. Older guides on the internet use master. GitHub uses main now. If a command fails with "branch master not found," try the same command with main.

That is the whole session. Your code is on the internet, with a link. From here on, every project you build this course ends the same way — a commit, a push, a link to share.

Resources

★ recommended