https://github.com/jscina/minigit
A minimalist version control system written in Rust, inspired by the core concepts of Git.
https://github.com/jscina/minigit
git rust
Last synced: about 1 year ago
JSON representation
A minimalist version control system written in Rust, inspired by the core concepts of Git.
- Host: GitHub
- URL: https://github.com/jscina/minigit
- Owner: Jscina
- License: mit
- Created: 2025-04-29T20:17:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-30T16:56:01.000Z (about 1 year ago)
- Last Synced: 2025-05-07T15:19:59.868Z (about 1 year ago)
- Topics: git, rust
- Language: Rust
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MiniGit ๐งช
A minimalist version control system written in Rust, inspired by the core concepts of Git.
MiniGit supports a basic local workflow:
- `init` a repository
- `add` files to a staging area
- `commit` changes with a message
- view the commit `log`
Ideal as a learning tool or tiny custom VCS for personal projects.
---
## ๐ Features
โ
`minigit init`
Creates a `.minigit/` directory with the required structure:
- `objects/`: stores file and commit blobs
- `index`: tracks staged files
- `HEAD`: tracks the latest commit
โ
`minigit add `
Stages files for commit by hashing their content and saving them to `objects/`.
- Supports globbing via shell (`minigit add src/*.rs`)
- Recursively adds directories
- Ignores files listed in `.minigitingore`
โ
`minigit commit -m "message"`
Creates a commit:
- Stores a JSON blob with timestamp, message, and staged file hashes
- Clears the index
- Updates `HEAD` to point to the new commit
โ
`minigit log`
Displays info about the latest commit:
- Commit hash
- Timestamp
- Commit message
- List of files and hashes
---
## ๐๏ธ Commit Format
Commits are stored as JSON inside Git-style blob objects:
```json
{
"message": "Initial commit",
"timestamp": "2025-04-30T15:00:00Z",
"files": [
{ "path": "src/main.rs", "hash": "5dd01c..." },
{ "path": "README.md", "hash": "9a2fe1..." }
]
}
```
---
## ๐ `.minigitingore`
Use this file in your root directory to ignore files or folders from being staged.
Example:
```
target/
*.log
*.rs.bk
```
---
## ๐ Build
```bash
cargo build --release && cp target/release/minigit /usr/local/bin
```
# Usage:
```bash
minigit init
minigit add src/
minigit commit -m "Add core logic"
minigit log
minigit --help
```
---
## ๐ฆ Dependencies
- [`clap`](https://crates.io/crates/clap) โ CLI argument parsing
- [`sha1`](https://crates.io/crates/sha1) โ Git-style hashing
- [`serde`](https://crates.io/crates/serde) + [`serde_json`](https://crates.io/crates/serde_json) โ commit serialization
- [`chrono`](https://crates.io/crates/chrono) โ timestamps
- [`anyhow`](https://crates.io/crates/anyhow) โ error handling
---
## ๐ License
MIT. Build cool stuff.