This project is a clone of the popular version control system, Git, built as part of the Codecrafters "Implement Your Own Git" challenge. It replicates Git’s functionality by implementing its underlying plumbing commands, which are internally invoked by porcelain commands rather than used directly. Developed in Rust, a modern and memory-safe language, this implementation ensures high performance and strong protection against low-level memory bugs.
- Initialize an empty git repository
- Create and read blob objects
- Create and read tree objects
- Create and read commit objects
- Clone a remote repository
git clone https://github.com/codebyred/git-rusty.git
cd git-rusty
cargo build
git-rusty <COMMAND>
init Initialize a new, empty Git repository
cat-file Provide content or type and size information for repository objects
hash-object Compute object ID and optionally create a blob from a file
ls-tree List the contents of a tree object
write-tree Write a tree object from the current index
commit-tree Create a commit object
clone Clone a repository into a new directory
help Print this message or the help of the given subcommand(s)
This project includes integration tests to ensure key functionalities work correctly.
write_tree_test
– Tests thewrite-tree
command functionality.commit_tree_test
– Tests thecommit-tree
command functionality.
Run all tests using:
cargo test
git-rusty/
├── .gitignore
├── Cargo.lock
├── Cargo.toml
├── LICENSE
├── README.md
└── src/
├── main.rs # Main entry point
├── object.rs # Git Object-related functionality
└── commands/ # Git command implementations
├── mod.rs # Module declarations for commands
├── cat_file.rs # Implements 'cat-file' command
├── clone.rs # Implements 'clone' command
├── commit_tree.rs # Implements 'commit-tree' command
├── hash_object.rs # Implements 'hash-object' command
├── init.rs # Implements 'init' command
├── ls_tree.rs # Implements 'ls-tree' command
└── write_tree.rs # Implements 'write-tree' command
- Rust – Programming language
- clap – Command-line argument parsing
- reqwest – HTTP requests (used with blocking feature)
- flate2 – Compression and decompression (e.g. zlib for Git objects)
- anyhow – Simple error handling library
- thiserror – Deriving custom error types
- bytes – Efficient buffer management
- hex – Hex encoding and decoding utilities
- sha1 – SHA-1 hashing (for Git object IDs)
- tempfile – Temporary file and directory utilities
- regex – Regular expressions library
- assert_cmd – Testing command line applications