Git and GitHub Basics

The getting started guide mentions GitHub Pages for hosting without explaining git itself. Here's what the two actually are, and the small set of commands that cover most day-to-day use.

Git vs GitHub

Git is a tool that tracks changes to your files over time, saving snapshots you can step back through or compare. It runs locally on your own computer and doesn't need an account or an internet connection to work.

GitHub is a website that hosts git projects online, at github.com. It needs a free account, and it's what actually serves your files if you use GitHub Pages for hosting. Git is the tool; GitHub is one place, among several, to put what it's tracking.

The basic commands

Inside a project folder, three commands turn it into a tracked git repository and save a first snapshot:

git init
git add .
git commit -m "first version"

init creates the repository. add . stages every file in the folder, marking it ready to be saved. commit saves that snapshot permanently, along with a short message describing what it contains.

Getting it onto GitHub

Create an empty repository on github.com, then connect your local folder to it and push your first commit up:

git remote add origin https://github.com/yourname/yourproject.git
git push -u origin main

remote add tells git where "origin" points to online. push uploads your commits there; -u remembers this pairing so future pushes don't need to repeat it.

The everyday loop

After that first push, the routine for every change afterward is just three lines:

git add .
git commit -m "describe what changed"
git push

Stage what changed, save a snapshot with a message, push it up. If you're hosting with GitHub Pages, each push updates the live site automatically within a minute or two.

← back to guides