An open API service indexing awesome lists of open source software.

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.

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.