PyGit is a custom implementation of the Git version control system, built from scratch in Python.
This project is an educational tool designed to explore and understand the core mechanics of Git, including its object model, staging area (index), branching, and command-line interface.
PyGit demonstrates how Gitβs powerful features are built upon a few simple and elegant concepts.
This version of PyGit implements the core plumbing and porcelain commands that cover the majority of a local, single-developer workflow.
initβ Initialize a new, empty PyGit repository
addβ Add file contents to the index (staging area)- Recursively adds files in directories
commitβ Create a new commit from staged fileslogβ View commit history (newest to oldest)
branchβ List all local branches or create a new branchcheckoutβ Switch between branches or restore a specific commit
statusβ Show the status of the working directory and staging areadiffβ Show line-by-line differences between working directory and indexcat-fileβ Inspect any object (commit, tree, or blob) by its hash
PyGit is built on the same fundamental principles as Git.
Everything in PyGit is stored as an object, identified by a unique SHA-1 hash computed from its contents.
This makes the database content-addressable and immutable.
- Blob β Stores the raw content of a file
- Tree β Represents a directory containing blobs and subtrees
- Commit β A snapshot of the project at a specific point in time
Includes:- Root tree hash
- Parent commit(s)
- Author and commit message
Also known as the staging area, the index maps file paths to blob hashes that will be included in the next commit.