A minimalist Git implementation written in Rust. This project demonstrates how version control systems work by reimplementing core Git functionality from scratch, using only essential Rust libraries for compression (flate2) and hashing (sha1).
git5 is a lightweight Git clone that implements the fundamental concepts of version control:
- Object storage (blobs, trees, commits)
- Reference management (branches, tags)
- Index/staging area
- Three-way file comparison
- Branch merging (fast-forward)
- Remote operations (clone, push, fetch)
init- Initialize a new repositoryadd- Stage files for commitcommit- Create a new commitlog- View commit historystatus- Show working tree statusdiff- View file changes
branch- List/create branchescheckout- Switch branches or restore filesmerge- Merge branches (fast-forward)
clone- Clone a repositorypush- Push to remotefetch- Fetch from remoteremote- Manage remotes
tag- Create/delete tagsstash- Stash changesreset- Reset HEADclean- Clean untracked files- And many more...
cargo build --release# Initialize a new repository
git5 init
# Add files to staging
git5 add .
# Commit changes
git5 commit -m "Initial commit"
# View history
git5 log
# Create a branch
git5 branch feature-branch
git5 checkout -b feature-branch
# Merge changes
git5 merge feature-branch- Blobs: File content
- Trees: Directory listings
- Commits: Snapshots with metadata
.git5/objects/- Object database.git5/refs/- References (branches, tags).git5/HEAD- Current HEAD.git5/index- Staging area
flate2- Zlib compressionsha1- SHA-1 hashingclap- CLI argument parsingsimilar- Text diffingureq- HTTP client for remote operations
- v0.1: Project foundation (blobs, trees, commits)
- v0.2: Branch system (branch, checkout)
- v0.3: Status management
- v0.4: Diff and merge
- v0.5: Local remote operations
MIT