A lightweight Git-inspired version control system built in Java to understand the core concepts behind Git. GitLite implements repository initialization, content-addressable storage, staging, commits, branching, checkout, and status using Java and the Java NIO API.
- Initialize a GitLite repository
- Stage files using SHA-1 hashing
- Store blobs in an object database
- Create commits with parent tracking
- View commit history
- Display repository status
- Create and list branches
- Switch between branches (checkout)
- Automated unit testing with JUnit 5
.gitlite/
├── objects/ # Blob storage
├── commits/ # Commit objects
├── refs/ # Branch references
├── HEAD # Current branch
└── index # Staging area
.\gradlew.bat run --args="init".\gradlew.bat run --args="add hello.txt".\gradlew.bat run --args="commit -m Initial".\gradlew.bat run --args="log".\gradlew.bat run --args="status".\gradlew.bat run --args="branch feature".\gradlew.bat run --args="branch".\gradlew.bat run --args="checkout feature"When a file is added:
- The file contents are read.
- A SHA-1 hash is generated.
- The contents are stored inside
.gitlite/objects. - The staging area (
index) stores:
filename=sha1hash
Each commit stores:
- Commit message
- Timestamp
- Parent commit ID
- List of tracked files
Commits are stored inside:
.gitlite/commits/
Each branch is represented by a file inside:
.gitlite/refs/
The HEAD file stores the currently checked-out branch.
- Java 21
- Gradle
- Java NIO
- SHA-1 Hashing
- JUnit 5
Run all unit tests:
.\gradlew.bat testThe project includes automated tests for:
- Repository initialization
- File staging
- Commit creation
- Branch creation
- Branch checkout
Potential enhancements include:
- Merge
- Reset
- Restore
- Diff
- Tags
- Remote repositories
- Push/Pull support
GitLite
├── app/
├── gradle/
├── src/
├── .gitignore
├── README.md
├── build.gradle.kts
├── settings.gradle.kts
├── gradlew
└── gradlew.bat
Aryaa Agarwal
Built as a learning project to understand how modern version control systems work internally.