gitoxide
A pure Rust implementation of Git — faster than C git for many operations, usable as both a library and a CLI tool.
gitoxide (invoked as gix or ein) is a complete reimplementation of Git in
pure Rust. It aims to be correct, fast, and lean — providing both a library
crate (gix) for embedding Git operations in Rust programs and a CLI tool for
everyday use. Many operations are significantly faster than the C git
implementation, particularly those that benefit from parallelism.
It is used as the Git implementation inside Cargo for fetching dependencies.
Features
- Pure Rust — no dependency on the system
gitbinary orlibgit2; all Git operations are implemented from scratch - Fast — parallelised object traversal, index reading, and pack operations are noticeably faster than reference git on large repositories
- Complete protocol support — SSH, HTTPS, and local transports; fetch, clone, push
- Correct — extensive test suite including compatibility tests against the C git reference implementation
- Library-first — the
gixcrate exposes a rich, well-documented API designed for embedding in other tools - Two CLIs —
gixfor low-level plumbing operations and repository inspection;einfor higher-level porcelain commands
Installation
cargo install gitoxide
This installs both the gix and ein binaries.
Or via package manager:
# macOS
brew install gitoxide
# Arch Linux
pacman -S gitoxide
# Nix
nix-env -iA nixpkgs.gitoxide
# Debian / Fedora
# Pre-built Linux binaries are available on the
# [releases page](https://github.com/Byron/gitoxide/releases).CLI Overview
gitoxide provides two binaries with different purposes:
gix— plumbing-level tool for inspecting and manipulating repository internalsein— porcelain-level tool for common workflows (closer to everydaygitusage)
Usage
Cloning and fetching
# Clone a repository
ein clone https://github.com/Byron/gitoxide
# Clone with a shallow depth
ein clone --depth 1 https://github.com/rust-lang/rust
# Fetch updates (inside a repo)
ein fetchRepository inspection with gix
# Show repository information
gix repo info
# List all objects in the repository
gix repo objects
# Verify the integrity of all objects
gix repo verify
# Show the tree of the current HEAD
gix tree entries
# Display a specific commit
gix commit show HEAD
# Walk the commit graph
gix revision list HEADIndex and working tree
# Show the current index
gix index entries
# Check for changes between index and working tree
gix index changesPack inspection
# List the contents of a pack file
gix pack entries .git/objects/pack/pack-*.idx
# Verify a pack file
gix pack verify .git/objects/pack/pack-*.pack
# Explode a pack into loose objects
gix pack explode .git/objects/pack/pack-*.packParallel operations
One area where gitoxide shines over C git is multi-threaded operations:
# Count all reachable objects (uses all CPU cores)
gix repo objects --count
# Compute statistics about the repository (parallel traversal)
gix repo statisticsUsing gix as a library
gitoxide's real power is as a library. It is used by Cargo itself for fetching and resolving crates:
cargo add gixuse gix::ThreadSafeRepository;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Open the repository in the current directory
let repo = gix::discover(".")?;
// Get HEAD commit
let head = repo.head_commit()?;
println!("HEAD: {}", head.id());
println!("Message: {}", head.message_raw()?);
// Traverse commit history
let commits = head.ancestors().all()?;
for commit_info in commits.take(10) {
let commit_info = commit_info?;
println!("{}", commit_info.id);
}
Ok(())
}Status
gitoxide is production-ready for library use — Cargo's use of gix for
dependency fetching is the most prominent endorsement. The CLI tools (gix and
ein) cover a growing subset of everyday Git operations, but are not yet a full
drop-in replacement for git in all workflows. The project's roadmap tracks
progress toward full porcelain coverage.
Why reimplement Git in Rust?
- Safety — C git has had numerous security vulnerabilities over the years; a Rust implementation eliminates entire classes of memory bugs
- Performance — Rust enables fearless concurrency; operations that C git does serially (pack traversal, object lookup) can be trivially parallelised
- Embeddability —
libgit2is the standard C library for embedding Git, but it lags behind git in features and has its own quirks;gixprovides a modern, ergonomic Rust-native alternative - Correctness by construction — Rust's type system and ownership model make many classes of Git protocol bugs impossible to express