A minimal, educational implementation of a Git-like version control system built from scratch in Java. This project demystifies Git's core internals by reproducing its fundamental design principles in a simplified, transparent form.
Git is often treated as a "black box" in daily development workflows. While we use high-level commands like commit, push, and merge, the underlying mechanisms—content-addressable storage, immutable objects, and directed acyclic graphs—remain abstract.
MiniGit aims to change this by providing a fully functional, minimal version control system that makes Git's internals accessible and understandable. Rather than replicating Git feature-for-feature, the focus is on clarity, correctness, and educational value.
MiniGit supports essential version control operations:
- Repository Initialization - Create new repositories with proper structure
- File Staging - Add files to the staging area (index)
- Committing - Create immutable snapshots of repository state
- History Viewing - Browse commit history and changes
- Status Checking - View repository status and staged changes
- Ignore Files - Support for
.minigitignoreto exclude files and directories - Native Binaries - Cross-platform native executables via GraalVM
MiniGit follows a clean, layered architecture that mirrors Git's conceptual design:
Command Line Interface (CLI)
↓
Command Orchestration Layer
↓
Domain Model (Git Objects)
↓
Storage Layer
↓
File System
- Filesystem as Database - All data stored as plain files
- Content-Addressable Storage - Objects stored by SHA hash
- Immutable Objects - Once written, objects never change
- Explicit State Transitions - Clear, deterministic behavior
.minigit/
├── HEAD # Current branch reference
├── index # Staging area
├── objects/ # Content-addressable object store
│ ├── ab/
│ └── cd/
└── refs/ # Branch references
└── heads/
└── main
- Java 21 or higher
- Maven 3.6+
- Clone the repository:
git clone https://github.com/regisx001/mini-git.git
cd mini-git- Build the project:
mvn clean compile- Create a runnable JAR:
mvn package- (Optional) Build a native executable (requires GraalVM):
mvn native:compileYou can run MiniGit using the compiled JAR or the native binary (if built).
Using the JAR:
alias minigit="java -jar target/minigit-0.1.4.jar"Using the native binary:
alias minigit="./target/minigit"Initialize a new repository:
minigit initAdd files to staging:
minigit add <filename>Create a commit:
minigit commit -m "Your commit message"View commit history:
minigit logCheck repository status:
minigit status.github/workflows/ # CI/CD pipelines (Maven, Release)
src/
├── main/java/com/regisx001/minigit/
│ ├── App.java # Main entry point
│ ├── cli/
│ │ └── CommandParser.java # CLI argument parsing
│ ├── core/
│ │ ├── Command.java # Command interface
│ │ ├── Repository.java # Repository state
│ │ ├── RepositoryLoader.java # Repository initialization
│ │ └── commands/ # Command implementations
│ ├── domain/ # Git object model
│ │ ├── Blob.java # File content objects
│ │ ├── Commit.java # Commit snapshots
│ │ ├── Tree.java # Directory structure
│ │ └── TreeEntry.java # Tree entries
│ ├── filesystem/
│ │ └── FileSystemService.java # Low-level file operations
│ ├── storage/ # Persistence layer
│ │ ├── IgnoreService.java # .minigitignore parsing
│ │ ├── Index.java # Staging area management
│ │ ├── ObjectStore.java # Object storage/retrieval
│ │ ├── RefStore.java # Reference management
│ │ └── TreeBuilder.java # Tree object generation
│ └── utils/
│ └── HashUtil.java # SHA-1 hashing
└── test/java/com/regisx001/minigit/ # Comprehensive JUnit 5 test suite
analysis/ # Design documentation
├── 01-introduction.md
├── 02-architecture-overview.md
├── 03-repository-structure-data-model.md
└── 04-uml-analysis.md
ROADMAP.md # Project roadmap and goals
MiniGit helps you understand Git's core concepts:
- Blobs: Immutable file content storage
- Trees: Directory structure representation
- Commits: Repository state snapshots
- References: Branch and HEAD pointers
- Index: Staging area for next commit
Each concept is implemented with minimal abstraction, making the code easy to follow and modify.
This is an educational project designed for learning. Contributions that enhance clarity, add documentation, or improve the codebase are welcome!
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For a deep dive into the design and implementation:
Built for educational purposes