Note:
The clone command in this project uses the git2 crate (libgit2).
Implementing the full Git smart HTTP protocol + packfile parsing turned out to be way bigger than expected during the
challenge, so I delegated that part to libgit2.
Everything else here was implemented manually.
Well… it's Git.
This is a small Rust project where I rebuilt parts of Git while doing the
Codecrafters Build Your Own Git challenge:
https://app.codecrafters.io/courses/git/overview
The goal was to understand how Git actually works internally instead of just using it.
These commands are implemented:
init
hash-object
cat-file
ls-tree
write-tree
commit-tree
clone
The core Git pieces are implemented:
blob → file contents
tree → directories
commit → snapshots of the project
Objects are stored in .git/objects using SHA-1 hashes, just like real Git.
cargo run -- init
cargo run -- hash-object -w file.txt
cargo run -- cat-file -p <hash>
cargo run -- write-tree
cargo run -- ls-tree --name-only <tree_sha>
cargo run -- commit-tree <tree_sha> -m "message"
cargo run -- clone <repo_url> <directory>
Mostly curiosity.
Git looks magical until you realize it's basically storing snapshots of files using hashes.
Rebuilding parts of it was a fun way to understand what actually happens inside .git.
Well… it's Git.