Web Technologies 2026 · BiUH

Git & GitHub

Your work gets a history — and goes online.

webtech.landrock.io

You have done this

about.html about-new.html about-final.html about-final-REALLY.html

There is a better way.

Why bother

Four questions you will ask this semester.

What did I just change?Git shows you, line by line.
When did it last work?Git has every version, with a date.
Can I go back?Git can — to any version you saved.
Is my work safe if my laptop dies?GitHub keeps a copy online.

Git answers the first three. GitHub answers the fourth — and lets other people see your work.

Part 1 · A bit of history

Fifty years of keeping track.

With a central server, no connection meant no saving. With Git, your laptop has everything — the internet is only for sharing.

Part 1 · April 2005

Linux loses its tool — and Linus writes a new one.

e83c516 Initial revision of "git", the information manager from hell — the very first commit in Git's own history · 7 April 2005

Part 1 · The name

"git" is British slang for
an annoying person.

Torvalds joked that he names all his projects after himself: first Linux, now git. The README called it "the stupid content tracker".

Stupid on purpose: Git does not understand your code. It only remembers exactly what every file looked like, and when.

Part 1 · 2008 — today

GitHub puts Git online.

It is not the only one: GitLab, Bitbucket and, in China, Gitee do the same job. The Git underneath is identical.

Linux's whole history is readable there too: github.com/torvalds/linux — more than a million commits.

Part 2

Explain it like
I'm five.

Part 2 · Git, explained with a game

Git is save points — for a folder.

💾 save→ the boss fight→ 💀 → load the save

"The AI rewrote my whole page" stops being a disaster. It becomes: load the last save.

Part 2 · Git, explained with photos

A commit is a photo of the whole folder.

91f0b3c
Build the four pages
index.html
quotes.html
project.html
about.html
c2a8e55
Add the useless machine
index.html
…
+ machine.html
7b03d1f
Link the machine from the nav
…
~ nav.html
e41c9a2
Add five project ideas
…
~ project.html
older→newer

Part 2 · GitHub, explained

GitHub is a copy of the album — online.

You work on your laptop with Git. Every so often, you send your new photos up to GitHub. That is a push.

Part 2 · The thing to get straight

Git is not GitHub.

Git

  • A program on your computer
  • Records the history of one folder
  • Works offline
  • Free and open source

GitHub

  • A website
  • Keeps a copy of that history online
  • Needs the internet
  • A company — owned by Microsoft

You can use Git without GitHub. You cannot use GitHub without Git.

Part 2 · Words you will hear

Eight words, and you can follow any Git tutorial.

repository · repoa folder Git is tracking, together with its whole history
commitone save point: a snapshot, a message, an author, a time, an id
stage · git addchoose what goes into the next commit
pushsend your new commits up to GitHub
pullbring down commits from GitHub that you do not have yet
clonedownload a whole repository, history included
remote · originthe copy on GitHub — origin is its usual nickname
mainthe name of your line of history

Part 2 · Three words do most of the work

add chooses. commit records. push sends up.

your folderwhere you edit
git add→choose
stagedpacked, ready to record
git commit→record
historyon your laptop
git push→send up
GitHubonline
← git pull brings it back down — on another computer, or after you changed something on github.com

add and commit work without internet. Only push and pull need it.

Part 2 · What a commit looks like

A snapshot of the folder — with a message.

e41c9a2 Add five project ideas and pick one
7b03d1f Link the machine from the nav
c2a8e55 Add the useless machine page
91f0b3c Build the four pages from the recap

Says nothing

  • update
  • fix
  • asdf
  • final final

Says what changed

  • Fix the broken image path on about.html
  • Make the header stack on phones
  • Add a label to the email field

This list is your 20% process grade. It grows week by week — and it cannot be written the night before.

Part 2 · Where the history lives

A hidden folder called .git.

my-site/
  .git/ ← the whole history
  index.html
  quotes.html
  project.html
  about.html
  style.css
  nav.html · nav.js
  • It appears when you run git init. Your files stay where they are.
  • Never edit it by hand. Delete it and the history is gone — the files remain.
  • One repository per project. Run git init inside my-site — never in your home folder or on the Desktop.

Cannot see it? It is hidden. That is normal — macOS: ⌘⇧. in Finder · Windows: View → Hidden items.

Part 3 · Installing it · first, check

Maybe you have it already.

git --version

✓ Ready

git version 2.47.1 — any 2.x is fine. Skip to "Tell Git who you are".

✗ Not installed

command not found or not recognized — install it, next slide.

The terminal inside VS Code is fine: Terminal → New Terminal.

Part 3 · Installing it

Five minutes, once.

Windows

  1. git-scm.com → Download for Windows
  2. Run the installer. The defaults are fine, except:
  3. Default editor → Visual Studio Code
  4. Initial branch name → Override → main
  5. Close VS Code completely, open it again

macOS

  1. Open Terminal, type git --version
  2. macOS offers the Command Line Tools → Install
  3. Wait a few minutes
  4. Type git --version again

Using Homebrew already? brew install git does the same.

Download crawling? The same Windows installer is mirrored on npmmirror.com (search "git-for-windows").

Part 3 · Once per computer

Tell Git who you are.

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main

git config --list        # check: your name and email should be there

A wrong email has stopped real deployments: the hosting service could not match the commit to an account, and refused to build.

Part 3 · Once · an account

A GitHub account.

GitHub slow or unreachable on your network? Gitee (gitee.com) works the same way — same Git, a different address. Tell me which one you use.

Part 3 · You do not need the terminal for everything

VS Code already speaks Git.

The buttons run exactly the same commands. Learn both: the buttons for speed, the commands so you know what the buttons do.

Part 4 · Your first repository · in the terminal

Put my-site under Git — and on GitHub.

# once per project
git init
git add .
git commit -m "Build the four pages from the recap"

# once: on github.com create a new, EMPTY repository called my-site, then
git remote add origin https://github.com/YOUR-NAME/my-site.git
git branch -M main
git push -u origin main

The terminal asks for a password? GitHub no longer accepts your account password here. Sign in through VS Code (next slide), and push again.

Part 4 · Your first repository · with buttons

The same, in VS Code.

  1. File → Open Folder → my-site
  2. Source Control → Initialize Repository
  3. Type a message: Build the four pages from the recap
  4. ✓ Commit — VS Code asks whether to stage all changes: Yes
  5. Publish Branch → sign in to GitHub → choose public
  6. Open github.com/your-name/my-site in a browser. It is there.

Public, because I need to see it — and so will the hosting that puts your site online.

Part 4 · What never goes in

Some files stay out — .gitignore.

.DS_Store
Thumbs.db
node_modules/
.env
  • A text file called .gitignore in my-site. Git pretends the files listed in it do not exist.
  • .DS_Store, Thumbs.db — junk your operating system leaves behind
  • .env — passwords and keys. Never commit it.

Pushed a password by accident? Change the password. Deleting the file is not enough — it is still in the history.

Part 4 · Every day after that

Commit when something works.
Push before you close the laptop.

Commit→Ask the AI→ Read→Test→Keep or undo
git status                         # what changed?
git add .
git commit -m "Say what changed"
git push

Commit before every AI prompt. If it breaks something, you are one click from where you were.

Part 4 · The commands that save you

Four questions, four commands.

You want to knowType
What have I changed since the last commit?git status
Exactly which lines?git diff
What did I do before?git log --oneline
Throw away everything since the last commitgit restore . · VS Code: Discard All Changes

git restore . cannot be undone — what was not committed is gone. That is the point of committing often.

Part 4 · Going back · with VS Code's own buttons

How far back do you need to go?

Back toClickWhat happens
The last commityou have not committed since it broke Source Control → hover a file → ↶ Discard Changes — or ↶ on Changes for all of them The files are exactly as they were at your last commit. What you had not committed is gone.
Before the last commitonly if you have not pushed it Source Control → ··· → Commit → Undo Last Commit The commit disappears. Its changes wait in the list — fix them, or discard them as above.
One file, further back"the nav worked last week" Open the file → Explorer → Timeline (at the bottom) → click a commit Then and now, side by side. Copy back the lines you need, then commit.
The whole site, further backto look, not to edit Source Control → Graph → right-click a commit → Checkout (Detached) Your folder turns into that version — open it with Live Server. Done? Click the commit ID, bottom left → main.

Already pushed? Do not undo it — fix it with a new commit. Once history is on GitHub, only add to it.

Part 4 · When it goes wrong · read the message

Git tells you what is wrong. Mostly in plain English.

It saysIt means
fatal: not a git repositoryYou are in the wrong folder. Open my-site.
Author identity unknownGit does not know who you are: run the two git config lines.
Support for password authentication was removedGitHub wants a sign-in, not your password: sign in through VS Code.
src refspec main does not match anyNothing committed yet — commit first, then push.
rejected … (fetch first)GitHub has a commit you do not: git pull, then push again.
Failed to connect to github.comThe network. Try again, or use Gitee.

Copy the message, read it out loud, then search it. That is not cheating — it is how everyone uses Git.

Not today

Branches, merging, pull requests —
they arrive when you need them.

Today: one line of history, and add · commit · push. That is most of what you will ever do with Git, every day.

Before you leave today

Check all five.

webtech.landrock.io/sessions

← → navigate · F fullscreen · P print · Copy never turns the page