https://github.com/sankhya007/my_git
own version control system
https://github.com/sankhya007/my_git
Last synced: 1 day ago
JSON representation
own version control system
- Host: GitHub
- URL: https://github.com/sankhya007/my_git
- Owner: sankhya007
- License: mit
- Created: 2025-10-30T17:13:02.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2025-10-30T18:54:20.000Z (8 months ago)
- Last Synced: 2025-10-30T19:37:00.859Z (8 months ago)
- Language: Python
- Size: 40 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MyGit - A Minimal Git Implementation in Python
[](https://www.python.org/downloads/)
[](LICENSE)
[](CONTRIBUTING.md)
## ๐ Overview
MyGit is an educational implementation of Git version control system written in Python. This project demonstrates the core concepts of Git internals while providing a functional version control system with advanced features like object caching, compression, and cross-platform support.
**๐ฏ Learning Focus**: Understand Git internals, content-addressable storage, and version control systems through clean, readable Python code.
## โจ Features
### โ
Core Features
- **Repository Management**: Initialize and manage repositories (`mygit init`)
- **Object Storage System**: Blobs, trees, commits with SHA-1/SHA-256 support
- **Staging Area**: Add files to staging (`mygit add`)
- **Commit System**: Create commits with author metadata (`mygit commit`)
- **History Viewing**: Browse commit history (`mygit log`)
- **Object Inspection**: Examine stored objects (`mygit cat-file`, `mygit hash-object`)
### ๐ Advanced Features
- **Object Caching**: LRU caching for performance optimization
- **Compression System**: Zlib compression with configurable levels
- **Delta Compression**: Efficient storage of similar objects
- **Streaming Support**: Memory-efficient large file handling
- **Cross-Platform**: Windows, Linux, and macOS compatibility
- **Colorized Output**: Beautiful terminal interface with progress indicators
## ๐๏ธ Architecture
mygit/
โโโ src/
โ โโโ objects/ # Git object system
โ โ โโโ blob.py # File content storage
โ โ โโโ tree.py # Directory structure
โ โ โโโ commit.py # Commit metadata
โ โ โโโ factory.py # Object factory with caching
โ โโโ commands/ # CLI command implementations
โ โ โโโ init.py # Repository initialization
โ โ โโโ add.py # Staging files
โ โ โโโ commit.py # Creating commits
โ โ โโโ log.py # History viewing
โ โโโ utils/ # Utility systems
โ โโโ hash_utils.py # Hashing and compression
โ โโโ file_utils.py # Cross-platform file operations
## ๐ Quick Start
### Installation
#### Method 1: Install as Package (Recommended)
```bash
# Clone the repository
git clone https://github.com/sankhya007/my_git.git
cd my_git
# Install in development mode
pip install -e .
```
#### Method 2: Run Directly
```bash
python src/cli.py --help
# or
python -m src.cli --help
```
### Basic Usage
```bash
# Initialize a new repository
mygit init
# Create and stage files
echo "Hello, MyGit!" > README.md
mygit add README.md
# Commit changes
mygit commit -m "Initial commit"
# View commit history
mygit log
# Inspect objects
mygit hash-object README.md
mygit cat-file -p
```
## ๐ Available Commands
### Basic Workflow
| Command | Description |
|----------|-------------|
| mygit init | Initialize new repository |
| mygit add | Stage files for commit |
| mygit commit -m "message" | Create new commit |
| mygit log | Display commit history |
### Object Inspection
| Command | Description |
|----------|-------------|
| mygit cat-file | Display object contents |
| mygit hash-object | Calculate object hash |
## ๐ง Advanced Configuration
### Compression Settings
```python
# In .mygit/config
[compression]
level = 6 # 1-9, higher = better compression
algorithm = zlib # zlib, lzma
enable_delta = true
```
### Performance Tuning
```python
[cache]
max_size = 1000 # Maximum objects in cache
strategy = lru # Cache replacement strategy
```
## ๐งช Testing
Run the test suite to verify your installation:
```bash
# Run all tests
python -m pytest tests/
# Run specific test module
python -m pytest tests/test_objects.py
# Run with coverage
python -m pytest --cov=src tests/
```
## ๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
### First Time Contributors
Check out issues labeled good-first-issue to get started with the codebase.
### Development Setup
```bash
# Fork and clone
git clone https://github.com/your-username/my_git.git
cd my_git
# Setup environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -e .
# Run tests
python -m pytest tests/
```
## ๐ Learning Resources
This project is excellent for understanding:
- Git Internals: Object model, references, pack files
- Content-Addressable Storage: SHA-based object retrieval
- Version Control Design: Delta compression, branching models
- Python Architecture: Package structure, CLI development, caching
**Recommended Reading**
- Pro Git Book
- Git Internals PDF
## ๐ Troubleshooting
### Common Issues
**Issue:** Command not found after installation
**Solution:**
```bash
export PATH="$HOME/.local/bin:$PATH"
```
**Issue:** Permission errors on Windows
**Solution:** Run as administrator or adjust permissions
**Issue:** Large file performance
**Solution:** Adjust compression settings in config
## ๐ Performance Notes
- Small Repositories: Comparable performance to Git
- Large Files: Streaming prevents memory issues
- Compression: Configurable levels for speed/size tradeoff
- Caching: Significant performance improvement for repeated operations
## ๐ฎ Roadmap
**Phase 1: Core Complete โ
**
- Basic object system
- Repository management
- Commit history
**Phase 2: In Progress ๐ง**
- Branching and merging
- Remote repository support
- Enhanced diff functionality
**Phase 3: Planned ๐**
- Git protocol implementation
- Hook system
- Performance optimizations
## ๐ฅ Contributors
We appreciate all contributions! See our Contributors Guide to get started.
## ๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
## โ ๏ธ Important Note
This is an educational implementation and should not be used for production version control. Always use the official Git client for important projects.
**MyGit - Understanding Git, one commit at a time. ๐**
If you find this project helpful, please give it a โญ on GitHub!