pit-cli
╔══════════════════════════════════════════════════════════════════╗
║ ║
║ ██████╗ ██╗████████╗ ║
║ ██╔══██╗██║╚══██╔══╝ ║
║ ██████╔╝██║ ██║ ║
║ ██╔═══╝ ██║ ██║ ║
║ ██║ ██║ ██║ ║
║ ╚═╝ ╚═╝ ╚═╝ ║
║ ║
║ A lightweight version control system built in Python. ║
║ Stage. Commit. Branch. Repeat. ║
║ ║
╚══════════════════════════════════════════════════════════════════╝
pit is a minimal yet functional version control system written in pure Python. It demonstrates Git-like functionality including object storage, branching, committing, and garbage collection.
Features
- 🚀 Lightweight: No external dependencies, pure Python implementation
- 📦 Object Storage: SHA1-based content-addressable storage system
- 🌿 Branching: Full branch support with easy switching
- 💾 Commits: Snapshot-based commit history
- 🗑️ Garbage Collection: Automatic cleanup of unreachable objects
- 🔍 Status & Log: View repository state and commit history
Installation
From PyPI (coming soon)
pip install pit-cli
From Source
git clone https://github.com/yourusername/pit-cli.git
cd pit-cli
pip install -e .
Quick Start
Initialize a repository
pit init
Add files
pit add <file_or_directory>
Commit changes
pit commit -m "Your commit message"
Create and switch branches
pit checkout -b new-feature
Switch to existing branch
pit checkout main
View commit history
pit log
Check status
pit status
List branches
pit branch
Delete a branch
pit branch -d branch-name
Run garbage collection
pit gc
Commands Reference
| Command | Purpose |
|---|---|
pit init |
Initialize a new repository |
pit add <path> |
Stage files/directories |
pit commit -m "msg" |
Create a commit |
pit checkout <branch> |
Switch to branch |
pit checkout -b <branch> |
Create and switch branch |
pit branch |
List branches |
pit branch -d <name> |
Delete branch |
pit status |
Show working tree status |
pit log [-n count] |
Show commit history |
pit gc |
Run garbage collection |
How It Works
Core Architecture
- Blob: Stores file content (uncompressed initially, then zlib-compressed)
- Tree: Represents directory structure, maps filenames to blob/tree hashes
- Commit: Captures a snapshot with tree reference, parent commits, and metadata
- Repository: Manages the
.pit/directory structure and all operations
Object Storage
Objects are stored in .pit/objects/XX/YYYYYY... where:
XX= first 2 characters of SHA1 hashYYYYYY...= remaining hash characters
Index & Staging
The index (.pit/index) tracks staged files:
{
"file1.txt": "sha1hash1",
"dir/file2.py": "sha1hash2"
}
Branches
Branches reference specific commits and are stored in .pit/refs/heads/:
.pit/refs/heads/main → commit hash
.pit/refs/heads/feature → commit hash
Development
Running Tests
python -m pytest tests/
Building the Package
pip install build
python -m build
Installing in Development Mode
pip install -e .
Project Structure
pit-cli/
├── pit/ # Main package
│ └── __init__.py # Core implementation
├── tests/ # Unit tests
├── README.md # This file
├── LICENSE # MIT License
├── pyproject.toml # Package configuration
└── main.py # CLI entry point (legacy)
Limitations
- No remote repositories: This is a local-only VCS
- No merge functionality: Switching branches replaces working tree
- No conflict resolution: Not applicable without merge
- No file permissions: Stores only content and basic metadata
- Single committer: No multi-user support
Contributing
Contributions are welcome! Areas for improvement:
- Merge functionality
- Remote repository support
- Improved performance for large repositories
- Better error handling and messages
- Comprehensive test suite
- Documentation and examples
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Created as a learning project to understand version control systems.
See Also
Metadata
Release files for pit-cli-ramaa 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pit_cli_ramaa-0.1.1.tar.gz | 35.3 kB | Without provenance | Details for pit_cli_ramaa-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pit_cli_ramaa-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pit_cli_ramaa-0.1.1-py3-none-any.whl |
Total release size: 45.4 kB
Release files / pit_cli_ramaa-0.1.1.tar.gz
| Download URL | pit_cli_ramaa-0.1.1.tar.gz |
|---|---|
| Size | 35.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15e5c253f827b877f3bec5979f598ad3764a26221b6e6f3f3dc134b74fa62ce4
|
|
BLAKE2b-256 checksum How to use checksums |
582c36d48504d545d85a55434f8443a1a2dde37bb5e8df2150246f18c9706996
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / pit_cli_ramaa-0.1.1-py3-none-any.whl
| Download URL | pit_cli_ramaa-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec9307fb26a6afd966a8e2a98a5b018edc47907e83d4a8567e57149fcffc1d01
|
|
BLAKE2b-256 checksum How to use checksums |
b73e5a7463e968a44ed60ce5c0cecced8ac785e374644d70d6006bc7434825cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for pit-cli-ramaa 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.