Project
MAR 2026

Pavan Dhadge

mgit

A Clear, Educational Git Clone Built from Scratch

mgit is a lightweight, user-friendly Git clone written entirely in C++ from the ground up.

Its single purpose: demystify Git internals by implementing core version control concepts with maximum clarity and minimal complexity — so you don’t just use Git, you finally understand it.

Unlike the real Git (which is massive and optimized for production), mgit strips everything down to essentials: clean code, readable logic, and transparent data flow. It’s perfect for learners, systems programming enthusiasts, or anyone who’s ever wondered “how does Git actually store commits and branches?”


Explore mgit on GitHub →

Motivation

Most developers run git commit dozens of times a day but never peek under the hood.
Questions like:

  • How are commits actually stored?
  • What’s a tree vs blob vs commit object?
  • How does branching/merging work without magic?
  • Why does git log reconstruct history so cleanly?

…stay unanswered because real Git is a ~100k+ line beast written for speed, not readability.

mgit exists to answer those questions by building a minimal but functional version control system that prioritizes transparency over completeness.

It’s my way of saying: “If I can understand Git by building a toy version, so can you.”

Approach & Philosophy

  • Clarity over completeness — only essential features, no bloat
  • Readability first — well-commented, modular C++ code (C++17)
  • Educational focus — every part is designed to be inspectable and understandable
  • SQLite-powered analytics — logs command usage, performance metrics, errors → gives insights into your workflow (not for core storage — objects are file-based like real Git)
  • Build simplicity — xmake + CMake, minimal deps (zlib, CLI11 vendored, no OpenSSL)

The result is a codebase you can read end-to-end in a weekend and actually learn from.

Core Features & Commands

  • mgit init — create a new repo
  • mgit add <file(s)> — stage changes
  • mgit commit -m "message" — create a commit
  • mgit status — see working tree & staged changes
  • mgit branch — list/create/delete branches
  • mgit switch <branch> — change branches
  • mgit merge <branch> — merge with basic conflict detection
  • mgit merge --continue / --abort — resolve or cancel conflicted merges
  • mgit log — view chronological commit history

Plus a unique Activity Analytics Suite (SQLite-backed):

  • mgit activity summary — command usage stats
  • mgit activity performance — timing insights
  • mgit activity recommendations — workflow tips based on your patterns

All core Git object model (blobs → trees → commits) is preserved — just simpler and inspectable.

Tech Stack & Build

  • Language: C++17
  • Build System: xmake (primary) + CMake support
  • Dependencies: zlib (compression), CLI11 (CLI parsing, vendored), SQLite3 (analytics/logging)
  • Internal: Custom SHA-1 implementation (no external crypto libs)
  • Platform: Currently Linux-focused (first release Feb 2026)

Quick Build & Run:

git clone https://github.com/pavandhadge/mgit.git
cd mgit
export XMAKE_GLOBALDIR=$PWD/.xmake-global
xmake f -m release
xmake
xmake run mgit -- --help

(Tests: xmake run test)

Why It Matters (to Me)

Building mgit forced me to confront Git’s elegance: how a few smart data structures (content-addressable objects, Merkle trees, refs) create such a powerful system.

It humbled me — and excited me.
Every time I run mgit log and see my toy history rendered cleanly, I feel a little closer to understanding one of the most beautiful pieces of software ever written.

If you’ve ever felt Git is “magic”, clone this repo, read the code, run the commands, inspect the .mgit dir — the magic disappears, replaced by understanding.

That’s the real win.

  • Repository & Docs: github.com/pavandhadge/mgit
  • Issues/PRs: Welcome — especially educational improvements, Windows support, or new analytics ideas

Try building it.
Break it.
Fix it.
Learn from it.

“mgit aims to strip away the complexity of Git while keeping the magic intact — so you not only use Git, you understand it.”