I Rebuilt Git Without Git — 3,390 Lines of Python, Zero Dependencies
Описание и применение
Создана полностью автономная система контроля версий, реализованная в одном файле Python без внешних зависимостей, с 141 тестом и 30 командами, включая собственный протокол синхронизации.
Задача
Reimplement a full Git‑like version control system using only Python’s standard library, eliminating external dependencies.
Результат
A fully functional Git‑like VCS implemented in a single Python file with no external dependencies, 141 tests, and a custom sync protocol.
Рабочий процесс
- 1. Design content‑addressed object model using hashlib.sha256 and zlib. 2. Implement staging area with JSON index mapping paths to blob hashes. 3. Build three‑way merge logic using difflib.SequenceMatcher. 4. Add 30 Git‑style commands (init, add, commit, branch, checkout, merge, etc.). 5. Create custom networking protocol over socket for clone/fetch/push. 6. Replace external libraries with stdlib equivalents (difflib, zlib, json, argparse, socket, fnmatch, unittest, os.walk). 7. Write 141 unit tests covering all features. 8. Verify reproducibility via SHA‑256 checksum of source file. 9. Run the tool with simple commands: python3 pygit_single.py init; python3 pygit_single.py add .; python3 pygit_single.py commit -m "First commit".
Доказательства
3,390 lines. 1 Python file. 141 tests. 30 commands. 0 external dependencies.
The substitution table ended up looking like this: GitPython / dulwich / pygit2 → My own implementation, difflib, zlib, json, argparse, socket, fnmatch, unittest, os.walk.
- Дата записи: 2026-09-07T21:29:14.817Z