DEV Community

Amit Kumar
Amit Kumar

Posted on

MyGit: A Git-Like Version Control System Built from Scratch in Python

MyGit: A Git-Like Version Control System Built from Scratch in Python

What if you could build a Git-like version control system without depending on the git executable?

That question led me to build MyGit, an independent, privacy-focused version control system written from scratch in Python.

MyGit provides its own repository structure, object database, staging index, commit graph, branching, merging, rebasing, cryptographic signing, secret scanning, remote server, and Python SDK.

Why MyGit?

MyGit is not a wrapper around Git.

It does not execute Git commands internally. Core functionality such as object creation, SHA-256 hashing, compression, index handling, graph traversal, and diffing is implemented natively in Python.

The project focuses on three important ideas:

πŸ” Security
πŸ”’ Privacy
🐍 Python extensibility

What Can MyGit Do?

🌳 Content-Addressed Storage

MyGit uses SHA-256 content addressing for Blob, Tree, Commit, and Tag objects.

This creates immutable and verifiable repository objects.

🌿 Branching, Merge & Rebase

MyGit supports branch management, 3-way LCA merges, conflict detection, merge continuation, and linear rebasing.

mygit switch -c feature/login

mygit add .
mygit commit -m "Add login feature"

mygit switch main
mygit merge feature/login
Enter fullscreen mode Exit fullscreen mode

πŸ” Cryptographic Commit Signing

MyGit supports Ed25519 key generation and signed commits.

mygit key generate
mygit commit -m "Signed release" --sign
Enter fullscreen mode Exit fullscreen mode

This provides cryptographic verification associated with commits.

πŸ›‘οΈ Secret Scanning

MyGit includes secret scanning for potential API keys, private keys, credentials, and high-entropy secrets.

mygit secrets scan
Enter fullscreen mode Exit fullscreen mode

The goal is to help prevent sensitive information from accidentally entering a repository.

πŸ”Ž Repository Integrity

MyGit provides repository health checking through:

mygit fsck
Enter fullscreen mode Exit fullscreen mode

It verifies repository objects, hashes, decompression, and references.

Garbage collection is available through:

mygit gc
Enter fullscreen mode Exit fullscreen mode

⚑ Offline-First

Core version-control operations can work completely offline.

Commands such as:

init
add
commit
status
log
branch
merge
rebase
fsck
Enter fullscreen mode Exit fullscreen mode

do not require an internet connection.

Network access is required only for remote operations and provider APIs.

🐍 Python SDK

MyGit can also be integrated directly into Python applications through its SDK.

from mygit_sdk import RepositorySDK

repo = RepositorySDK.open(".")

status = repo.status()

repo.add("app.py")

sha = repo.commit(
    "Add app module",
    author="Developer <dev@example.com>"
)

print(sha)
Enter fullscreen mode Exit fullscreen mode

This makes it possible to integrate version-control functionality into Python applications, developer tools, IDE extensions, and automation workflows.

🌐 Remote Server & Web Dashboard

MyGit includes a FastAPI-based remote server and a React web dashboard.

The project also includes provider integrations for GitHub, GitLab, and Hugging Face.

πŸ“¦ Install MyGit

You can install MyGit directly from PyPI:

pip install mygit
Enter fullscreen mode Exit fullscreen mode

Then verify the installation:

mygit --version
Enter fullscreen mode Exit fullscreen mode

🚧 Current Project Status

MyGit is currently under active development.

The core version-control engine, 3-way merge, rebase, cryptographic signing, repository integrity checks, local server APIs, Python SDK, and PyPI packaging are implemented and tested.

Cloud synchronization and some provider integrations are still being expanded.

πŸ—ΊοΈ What's Next?

The roadmap includes continued development around:

🌐 GitHub and GitLab synchronization
πŸ€— Hugging Face workflows
πŸ“ Large-file synchronization
βš™οΈ Containerized CI/CD workers
☁️ Remote repository capabilities
πŸ› οΈ Additional developer tooling

Final Thoughts

MyGit started as an experiment to understand what happens underneath a version-control system.

Instead of simply using Git, I wanted to explore the fundamentals:

Objects β†’ Hashes β†’ Trees β†’ Commits β†’ References β†’ Graphs β†’ Merges β†’ Repositories

Building these components from scratch has been a great way to explore version-control internals while experimenting with security, privacy, and Python extensibility.

If you're interested in Python, version control, developer tools, security, or open source, I'd love to hear your feedback.

πŸ“¦ PyPI: https://pypi.org/project/mygit

Python #OpenSource #VersionControl #Git #DevTools #SoftwareDevelopment #Security #PythonDevelopment

Top comments (0)