Teach Git with a game
Students push before they pull, can't see the layers between their editor and the remote, and are afraid of losing work. In Git Game each of those happens to them inside a minute, in Git's own words, with nothing to install and no account to make. Here is a 45-minute lesson, what to say at each step, and a deck to print.
What they can say afterwards
- What a fast-forward is, and why a push is rejected without one.
- What a pull does before a push, and the choice it carries: rebase or merge, and whose lines win a clash.
- What a forced push erases, and what brings it back.
- That history is shared: a day closes with everyone's packs, in an order nobody chose.
The lesson, 45 minutes
-
15 minutes: the guided game
Everyone opens
gitgame.online/playon anything with a browser and taps play the bot. The first game is guided: one thing highlighted and one sentence per step, for the first days. Days last 60 seconds, and a day ends early once both packs are in, so twelve days take about ten minutes. Then two minutes: who saw! [rejected], and what did the bot say it was doing? -
20 minutes: a room, then the replay
One student opens a room and shares its link; that link is the whole invitation, three to five seats, bots in any left empty, 60-second days. Twelve minutes of play. Then put one game's replay on the screen, day by day, and stop at the first rejection, the first conflict, the first
push --force: what did Git say, and why? -
10 minutes: the map
What happened in the game, what it is in Git, and where to read more, from the table below. End on the question the game can't answer for them: what would you have done in a real repository?
Homework, if you like: a room on 24-hour days. Seven days, one pack a day, reminders if they ask for them, and a week of thinking about a push before making it.
The map
| In the game | In Git | Read |
|---|---|---|
| Your push was rejected | A non-fast-forward: someone's commit reached main first |
My push was rejected |
| The pull chose whose lines win | A merge conflict, settled by -X ours or -X theirs |
Merge conflict |
A push --force erased a commit |
A forced update; the reflog brings it back | Someone force-pushed over my commit |
CI flipped a bug; someone played blame |
git blame, git bisect |
Who broke main |
A revert on a bug |
git revert: a commit that undoes a commit |
Undo a commit that's on main |
Why it works on the things that are hard to teach
- Push before pull. The most common mistake in a first Git lesson is a pack in this game: a push from behind is rejected in Git's words and the op is spent. The habit of pulling first forms in a game, not in a repository that matters.
-
The invisible layers. Working copy, staging, local branch, remote: the hub draws them as
zones, and
add,commitandpushmove cards between them. Students see the layer a command works on before they type it anywhere. -
Fear of losing work. The game is where losing it is safe:
push --forceerases,reflogrestores, and every day can be replayed. The lesson on what Git keeps is on the lost commit page. - Git as a solo tool. The day closes with everyone's packs, resolved together in a random order. There is no turn to wait for, and the other players are the reason anything goes wrong.
Running it
- What you need. A browser per student, a phone is fine, and one screen for the replay. Nothing to install.
-
Privacy. Nothing to sign up for. A device gets a made-up handle, like
quiet-otter-42, and a cookie. The server keeps the games played with it and, during the beta, that a player came back. No name and no email, unless a student links a GitHub account or asks for reminders by email; both are optional and off until asked for. - Levels. Someone who has never used Git has the guide; someone who has will find the details right, down to the flags.
- A draft. The rules are v0.2 and the beta is the playtest, so a rule may change between terms. Every game ends with a box for telling us how it went; the pages about Git's output describe the rules as they are.
The deck, to print
The game began on paper, and the paper version is free to print: sixteen US Letter pages, nine poker-size
cards to a page. Sixty commit cards, twelve of them bugs, the command cards, the incidents, a token sheet and
a one-page reference. Three to five players, about 45 minutes, and it has cards the online game doesn't play
yet, bisect, cherry-pick, stash among them, which is a lesson in
itself.
download the deck (PDF) the rules
- Print at actual size, single-sided, no fit-to-page: the cards are 2.5 by 3.5 inches.
- Card stock, or sleeves with opaque backs. A face-down bug must not be readable through the paper, or the bluff is gone. No card backs are printed, by design: every card in the draw deck shares a blank back.
- You also need coins or clips to mark pointers, a six-sided die for the Flaky CI incident, and a pen.
The deck and the text of these pages are under CC BY-SA 4.0: copy it, change it, print it for a class or a paid workshop; keep the licence and say where it came from.