Skip to content

Try “polymorphism”, “TCP handshake” or “git rebase”.

    Computer Basics / Git

    The Whole Story

    The whole module retold as one story — no new facts, a fast revision of Git.

    Extra: Revision3 min read

    Git is a photo album of your project, and every developer holds the complete album — it's distributed (Ch 1). You arrange a shot in the staging area with git add, then take the photo with git commit (Ch 2). Every photo is a full snapshot, stored as blobs (files) inside trees (folders) referenced by a commit — each named by a hash fingerprint that also covers its parent, so history can't be secretly altered (Ch 3).

    A branch is just a movable bookmark — a file holding one commit hash — and HEAD is the "you are here" arrow; branches cost nothing, so every piece of work gets one (Ch 4). To combine work, Git merges: sliding a bookmark forward when it can, or doing a three-way merge with a two-parent merge commit, and stopping at conflicts where a human must choose (Ch 5). Or it can rebase: replay your commits on top of the latest work for a straight-line history — only ever for commits no one else has (Ch 6).

    The shared album in the library is a remote — origin on GitHub. You clone it once, fetch to see what's new, pull to bring it into your branch, and push to share, never --force onto shared work (Ch 7). Teams keep main always deployable and bring every change in through a reviewed, tested pull request from a short-lived feature branch (Ch 8).

    Mistakes have tools: restore for uncommitted edits, amend and reset for commits only you have, revert for pushed commits, stash to park work, and the reflog as a safety net for anything once committed (Ch 9). Secrets, dependencies and huge files stay out through .gitignore — and a leaked secret is rotated first, cleaned second (Ch 10). And when something breaks, diff, log, blame and above all bisect — a binary search through history — find exactly which commit did it (Ch 11).

    Part 0's five problems, solved: one true version with history (commits), no lost work when two people edit (branches and merges), finding the breaking change (bisect, blame), going back to Tuesday (reset, revert, switch), and a stolen laptop costs nothing (every clone is a full backup).