GitCraft
A Git-compatible command-line implementation in Rust. I built object storage, tree and commit creation, smart-HTTP cloning, packfile and delta handling, and working-tree checkout for a focused subset of Git.
- Scope
- Individual
- Status
- Built subset
- Stack
- Rust · Git protocol · Smart HTTP · SHA-1 · zlib
01 Context
The problem
Git's familiar commands hide a compact set of storage formats and network exchanges. GitCraft makes that machinery concrete by producing compatible objects and reconstructing a repository from the smart-HTTP clone path.
My role
I implemented this project individually, focusing on the object model and clone data path rather than trying to reproduce every Git command and edge case.
- Built loose blob, tree, and commit storage with Git-compatible encoding.
- Implemented upload-pack negotiation, pack parsing, and delta reconstruction.
- Restored reconstructed objects into a working-tree checkout.
02 Architecture
System at a glance
03 Decisions & trade-offs
Objects make the repository
Loose objects are encoded with Git’s type-and-length header, addressed by SHA-1, compressed with zlib, and stored under their derived path. Recursive tree construction turns filesystem entries into an object graph; commit creation then points to a tree and its parent history.
The implemented local commands are init, cat-file, hash-object, ls-tree, write-tree, and commit-tree. That boundary is visible because compatibility is more useful when its limits are explicit.
Clone is a binary data pipeline
The clone path discovers references and requests objects through Git’s smart-HTTP upload-pack flow. The response is parsed as a packfile rather than treated as an archive. Base objects are decoded first, then offset and reference deltas are applied to reconstruct their final bytes.
Binary lengths, variable-width encodings, and delta instructions demand defensive cursor management. Rust’s result types and bounded parsing help keep malformed input from becoming unchecked indexing or partial output.
Materialization comes last
Reconstructed objects are written into the local object database before the selected tree is walked into the working directory. Keeping network exchange, object reconstruction, storage, and checkout as distinct stages made the end-to-end flow easier to reason about.
Clippy passes with warnings denied, but the current test command reports zero tests. That is a real limitation: the next useful work is a compatibility matrix and deterministic fixtures for hashes, packfiles, deltas, and checkout—not a broader claim about replacing Git.
04 Evidence
Inspect the work
- Source code (opens in a new tab)Public repository
- Verification (opens in a new tab)Clippy passed with warnings denied; cargo test passed with zero tests
Current status & limitations
- GitCraft implements a focused command subset, not a full Git replacement.
- The repository currently has no automated test cases.
- Unsupported protocol variants and repository edge cases need an explicit matrix.