💾 Gitlet: Lightweight Version Control in Java
Role
Developer
Tools & Concepts
Java, Mac CLI, data structures, hashing, content addressing, file persistence
Timeline
1 month
Summary
Gitlet is a Java-based implementation of Git that replicates its core version control mechanics using file operations. It models Git’s architecture by storing blobs (file contents), commits (snapshots of the project state), and branch pointers inside a .gitlet directory.

Files and commits are serialized and identified with a SHA-1 hash of on their contents. Each commit keeps track of which file versions it includes and links back to earlier commits, forming a timeline of changes. Gitlet supports commands like init, add, commit, checkout, log, and merge by directly manipulating these serialized objects, mimicking Git’s internal logic without relying on any existing Git libraries.
Project Background
Why did I build this?
To teach myself Java, I took UC Berkeley's CS61B: Data Structures course, which is completely free and public! Gitlet is the second of 3 major projects in this course, and served as my introdution to applying data structures in a fully functional project, all from scratch. You can find my code here.
Gitlet can be tricky to grasp if you don't understand Git - this article by Mary Rose Cook excellently breaks down how Gitlet works: