BeginnerDeveloper Workflow

Git Save Game — 用游戏存档理解 Git

An interactive game that teaches Git internals (Blob, Tree, Commit, Branch, Merge) using the perfect metaphor: RPG game saves.

10 min
Git, Version Control, Interactive

Prerequisites

  • No coding experience required — just curiosity!
🎮

Git Save Game — 用游戏存档理解 Git

Interactive tutorial • Click through each chapter

🎮 Chapter 1: Blob — 道具数据

Every item in the game world is stored as a Blob

在游戏世界里,每个道具都是一段纯数据。一把铁剑、一瓶药水——它们不知道自己在谁的背包里,只保存自己的属性。Git 的 Blob 也完全一样:纯内容,不关心文件名或路径。

🎒 Working Inventory (工作区)
⚔️Slot 1:铁剑 ATK+10
🧪Slot 2:生命药水 HP+50
🛡️Slot 3:皮甲 DEF+5
📦 Git Object Store (.git/objects)

Empty — start storing items!

Git = 游戏存档系统

你有没有想过,Git 到底是怎么工作的?其实它的设计和游戏存档系统完全一致:随时可以回到过去,也可以开辟平行宇宙(支线任务),搞砸了还能读档重来。

上面的交互式游戏会带你一步步理解 Git 的四个核心概念:

🎯 Core Concepts Recap

Git ConceptGame Save AnalogyWhat It Actually Stores
Blob道具数据 (Item Data)Pure file content — no name, no path
Tree背包结构 (Inventory Map)Directory structure — maps names to Blobs
Commit存档封面 (Save Record)Metadata + pointer to Tree + parent link
Branch存档槽位 (Save Slot)Lightweight label pointing to a Commit
Merge合并平行宇宙 (Combine Timelines)A special Commit with two parents

🔑 Key Insight

When you run git commit, here's what actually happens:

  1. Blobs are created for each file's content
  2. Trees are created to record the directory structure
  3. A Commit object is created with metadata and a pointer to the root Tree
  4. The current Branch label moves forward to point at the new Commit

That's it! The entire Git system is built from these four simple objects.

💡 Why This Matters

Because everything is linked by hash pointers:

  • Switching branches is instant (just moving a label)
  • Git can detect if anything changed (hash mismatch)
  • Old data is never lost until you explicitly garbage-collect
  • Merging is just creating a new Commit that points to two parents

This tutorial is part of the Developer Workflow series.

Part of Developer Workflow