Skip to main content

004 · UC Berkeley CS61B — Gitlet

项目 内容
学校 UC Berkeley
课程 UC Berkeley CS61B Data Structures
方向 数据结构 / Data structures
语言 Python
难度 进阶 / Intermediate–advanced
预计耗时 5–10 天 / 5–10 days

为什么收录

Gitlet 让学生从零实现一个简化版 Git:内容寻址存储、提交图、暂存区。概念简单但工程细节多,是锻炼”把抽象概念落地成持久数据结构”的极佳题目。

Gitlet asks students to build a simplified Git from scratch: content-addressable storage, commit graphs, and a staging area. Simple concepts, but rich engineering detail.

English: Gitlet teaches that version control is just a handful of data structures — snapshots, hashes, and parent pointers — assembled carefully.

实测结果

  • 3 次提交(initial + 2),log 按 newest-first 显示 / 3 commits, log newest-first
  • checkout 把改坏的文件恢复为 HEAD 版本('hello gitlet\n')/ restore verified
  • 记录并修复了一个真实的”uid 哈希不一致”bug / a real hash-consistency bug found and fixed
  • 详见 05-调试与测试.md

七章解析

题目解读 · 设计思路 · 逐步实现 · 正确性与复杂度 · 调试与测试 · 踩坑清单 · 延伸练习

源码与测试

题目目录 · 参考实现 · 测试