A simplified version control system written in Rust. Built from scratch to understand how Git works under the hood — from object hashing and storage to repository initialization.
Most of us use git every day without questioning what happens under the hood. This project is a learning exercise to answer questions like:
- How is a file stored as a blob object?
- What does content-addressable storage really mean?
- What actually happens when you run
git init?
bit init— initializes a repository (.bitdirectory withobjects,refs,HEAD, andindex)bit object create <path>— creates a blob object from a file (SHA-1 hash + zlib compression, same scheme as Git)bit object cat-object <hash>— reads and decompresses an object by its hash- CLI stubs for
clone,commit, andpush(work in progress)
cargo build# Initialize a repository
bit init
# Create an object from a file
bit object create path/to/file.txt
# Read an object back by its hash
bit object cat-object <hash>Like Git, bit stores content-addressable objects:
- A header is built as
blob <size>\0<content> - The header + content are hashed with SHA-1
- The object is compressed with zlib and stored at
.bit/objects/<first 2 chars of hash>/<remaining hash>
bit walks up the filesystem from the current directory until it finds a .bit directory, mirroring how Git finds the repo root.
src/
├── main.rs # CLI entry point (clap)
├── internals/
│ ├── objects.rs # Object creation and reading (blob/tree)
│ └── database.rs # Object database (in progress)
├── phases/
│ ├── init.rs # Repo initialization
│ └── index.rs # Index/staging (in progress)
├── hashing/ # Hashing logic (in progress)
├── traits/ # Shared traits
└── utils/
└── path.rs # Filesystem utilities
- Tree objects for directories
- Commit objects
- Staging area / index
-
clonesupport -
commitsupport -
pushsupport