A beginner-friendly Git-like version control system
Project description
Sid โ A Beginner-Friendly Git-like Version Control System
๐ง Build your own VCS from scratch. Learn Git internals by doing.
Sid is a fully-functional version control system written in pure Python.
Instead of git, you use sid. It's designed for students and beginners
who want to understand how Git works under the hood.
Key Features:
- โ 50 commands across 11 levels of functionality
- โ Built with only Python standard libraries (no external deps)
- โ Clean, commented code that explains every concept
- โ Cross-platform: Windows, Linux, macOS
- โ
Installable CLI โ just run
sidfrom anywhere
Quick Start
Installation
# Clone or download this project
cd sid
# Install in development mode
pip install -e .
# Verify installation
sid version
Your First Repository
mkdir my-project
cd my-project
# Initialize a new Sid repository
sid init
# Create a file
echo "Hello, Sid!" > hello.txt
# Check what's happening
sid status
# Stage the file
sid add hello.txt
# Commit it
sid commit -m "first commit"
# View the history
sid log
Command Reference
Level 1 โ Core Commands
| Command | Description |
|---|---|
sid init |
Initialize a new .sid repository |
sid add <file> |
Stage a file for commit |
sid add . |
Stage all files recursively |
sid commit -m "msg" |
Create a commit from staged files |
sid status |
Show working tree status |
sid log |
Show commit history |
sid diff |
Show unstaged file differences |
sid diff --staged |
Show staged differences |
Level 2 โ File Restore / Reset
| Command | Description |
|---|---|
sid restore <file> |
Restore file from index |
sid restore --source HEAD <file> |
Restore file from last commit |
sid rm <file> |
Remove file from tracking |
sid reset |
Unstage all files |
sid reset <file> |
Unstage a specific file |
sid reset --hard |
Reset everything to HEAD โ ๏ธ |
Level 3 โ Branching
| Command | Description |
|---|---|
sid branch |
List all branches |
sid branch <name> |
Create a new branch |
sid branch -d <name> |
Delete a branch |
sid checkout <branch> |
Switch to a branch |
sid checkout -b <name> |
Create and switch to new branch |
sid switch <branch> |
Switch (alias for checkout) |
sid switch -c <name> |
Create and switch (alias) |
Level 4 โ Commit Inspection
| Command | Description |
|---|---|
sid show [ref] |
Show commit details |
sid show HEAD |
Show latest commit |
sid cat-file <hash> |
Print raw object content |
sid ls-files |
List tracked files |
Level 5 โ Merge
| Command | Description |
|---|---|
sid merge <branch> |
Merge branch into current |
sid merge --abort |
Abort in-progress merge |
Level 6 โ Tags
| Command | Description |
|---|---|
sid tag |
List all tags |
sid tag <name> |
Create a lightweight tag |
sid tag -d <name> |
Delete a tag |
sid checkout <tag> |
Checkout tag (detached HEAD) |
Level 7 โ Ignore File
| Command | Description |
|---|---|
.sidignore |
Create to define ignore patterns |
sid check-ignore <file> |
Check if a file is ignored |
Level 8 โ Configuration
| Command | Description |
|---|---|
sid config user.name "Name" |
Set your name |
sid config user.email "email" |
Set your email |
sid config --list |
Show all config entries |
Level 9 โ Stash
| Command | Description |
|---|---|
sid stash |
Save uncommitted changes |
sid stash list |
Show saved stashes |
sid stash apply |
Apply latest stash |
sid stash pop |
Apply and remove stash |
Level 10 โ Local Remotes
| Command | Description |
|---|---|
sid remote add origin <path> |
Add a local remote |
sid remote -v |
Show configured remotes |
sid clone <src> <dest> |
Clone a repository |
sid push origin main |
Push to remote |
sid pull origin main |
Pull from remote |
Level 11 โ Utilities
| Command | Description |
|---|---|
sid help |
Show all commands |
sid version |
Show version |
sid doctor |
Check repository health |
sid graph |
Show commit graph |
sid clean |
Remove untracked files |
How Sid Works Internally
The .sid Directory
When you run sid init, a hidden .sid folder is created:
.sid/
โโโ objects/ โ Stores file content & commits (by hash)
โโโ refs/
โ โโโ heads/ โ Branch pointers (e.g., main โ commit hash)
โ โโโ tags/ โ Tag pointers
โโโ stash/ โ Saved stash entries
โโโ HEAD โ Points to current branch
โโโ index โ Staging area (JSON)
โโโ config โ Repository settings (JSON)
Content-Addressed Storage
Every file's content is hashed using SHA-1, producing a 40-character hex string.
The content is stored in .sid/objects/<hash>. If two files have the same content,
they share the same object โ this is called deduplication.
"Hello, World!\n" โ SHA-1 โ "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b"
The Index (Staging Area)
The index at .sid/index is a JSON file mapping file paths to their blob hashes:
{
"hello.txt": "a0b659396...",
"src/main.py": "f3e2d1c0b..."
}
When you run sid add, the file is hashed and added here.
When you run sid commit, this snapshot becomes the commit.
Commit Objects
A commit is also stored in .sid/objects/ as a JSON file:
{
"type": "commit",
"message": "first commit",
"author": "Siddhant",
"email": "sid@example.com",
"timestamp": "2025-01-01T12:00:00+00:00",
"parent": null,
"files": {
"hello.txt": "a0b659396..."
}
}
Commits form a linked list โ each commit points to its parent.
Branches
A branch is just a file in .sid/refs/heads/ containing a commit hash.
HEAD tells Sid which branch you're currently on:
HEAD โ "ref: refs/heads/main"
refs/heads/main โ "abc123..." (commit hash)
Common Errors and Fixes
| Error | Fix |
|---|---|
| "not a sid repository" | Run sid init first |
| "nothing to commit" | Stage files with sid add |
| "cannot create branch โ no commits yet" | Make your first commit |
| "cannot delete current branch" | Switch to another branch first |
| "merge conflict" | Edit the conflicted files, sid add them, then commit |
Example Workflow
# Create a project
mkdir demo && cd demo
sid init
sid config user.name "Siddhant"
sid config user.email "sid@example.com"
# Create and commit files
echo "hello sid" > hello.txt
sid add hello.txt
sid commit -m "first commit"
# Make changes
echo "updated" >> hello.txt
sid diff
sid add hello.txt
sid commit -m "update hello"
# Branching
sid branch dev
sid checkout dev
echo "dev work" > dev.txt
sid add .
sid commit -m "add dev work"
# Merge
sid checkout main
sid merge dev
# Inspect
sid log
sid graph
sid show HEAD
sid doctor
Future Improvement Ideas
- ๐๏ธ Compression โ Compress blob objects (zlib) to save space
- ๐ฆ Binary file support โ Better handling of images, PDFs, etc.
- ๐ง 3-way merge โ Use common ancestor for smarter merging
- ๐ Real remote server โ Push/pull over HTTP or SSH
- ๐ฅ๏ธ Web dashboard โ Browse commits and diffs in a browser
- ๐ GitHub-like hosting โ Self-hosted repository server
- ๐ Plugin system โ Custom hooks and extensions
- ๐จ GUI app โ Visual interface for Sid operations
- ๐ Blame command โ Show who changed each line
- ๐ Bisect โ Binary search for bug-introducing commits
- ๐ Cherry-pick โ Apply specific commits to another branch
- ๐ Interactive rebase โ Rewrite commit history
Project Structure
sid/
โโโ sid/
โ โโโ __init__.py # Version constant
โ โโโ cli.py # CLI entry point (argparse)
โ โโโ repository.py # Repository initialization
โ โโโ objects.py # Blob & commit object storage
โ โโโ index.py # Staging area management
โ โโโ commit.py # Commit creation & log
โ โโโ status.py # Working tree status
โ โโโ diff.py # Unified diff display
โ โโโ restore.py # File restoration
โ โโโ reset.py # Index/tree reset
โ โโโ branch.py # Branch CRUD
โ โโโ checkout.py # Branch/tag switching
โ โโโ merge.py # Branch merging
โ โโโ tags.py # Lightweight tags
โ โโโ ignore.py # .sidignore patterns
โ โโโ config.py # Configuration management
โ โโโ stash.py # Stash save/apply
โ โโโ remote.py # Local folder remotes
โ โโโ graph.py # Commit graph display
โ โโโ clean.py # Remove untracked files
โ โโโ doctor.py # Repository health check
โ โโโ utils.py # Shared helpers
โโโ tests/
โ โโโ test_init.py
โ โโโ test_add_commit.py
โ โโโ test_branch.py
โ โโโ test_status.py
โโโ README.md
โโโ pyproject.toml
โโโ .sidignore.example
Running Tests
# Install dev dependencies
pip install -e ".[dev]"
# Run all tests
python -m pytest tests/ -v
# Run a specific test file
python -m pytest tests/test_init.py -v
License
MIT License โ Feel free to use, modify, and learn from this project.
Built with โค๏ธ for learning. Happy hacking!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sid_vcs-1.0.0.tar.gz.
File metadata
- Download URL: sid_vcs-1.0.0.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a392c35de0755ee7e036ddbe86de03ef4d41d82acc264f770d54af74c880189
|
|
| MD5 |
2fc5377db4e9e04ebfa350464b5da85d
|
|
| BLAKE2b-256 |
72a130f54d2ce0344ed99832b5b8f790eded3db268bf91d1dca35d240d6a2ca4
|
File details
Details for the file sid_vcs-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sid_vcs-1.0.0-py3-none-any.whl
- Upload date:
- Size: 45.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e004463e7af19bc6a66ba5cebb6fe78baac4fbaeb0c334f27fe67e66402ec96f
|
|
| MD5 |
1a277e4fb6ee2f7f678326959246c9a8
|
|
| BLAKE2b-256 |
713b89893e593af1ce4b364a1df05025fa9e417c3083f4dc87de1bfdbe0125af
|