Skip to content

Mathieu-Le-Gouill/Mini-Git

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mgit

A minimal Git-like version control system written in Python.

Installation

make dev        # editable install (recommended)
pip install .   # standard install

Commands

mgit init                      Initialize a new repository

mgit add <files>               Stage specific files
mgit add .                     Stage all new and modified files
mgit add -A, --all             Stage all changes including deletions

mgit commit -m <msg>           Commit staged changes
mgit commit -a -m <msg>        Auto-stage tracked changes then commit

mgit status                    Show branch, staged and unstaged changes
mgit status -s, --short        Compact XY status format

mgit diff [files]              Staged files vs working directory

mgit branch                    List branches
mgit branch -v, --verbose      List branches with last commit info
mgit branch <name>             Create a branch
mgit branch -m <name>          Rename the current branch
mgit branch -d <name>          Delete a branch

mgit checkout <name>           Switch to a branch
mgit checkout -b <name>        Create and switch to a new branch

mgit merge <branch>            Merge a branch into the current branch

mgit help                      Show the help message

How it works

mgit stores all data inside .mgit/ in the working directory:

.mgit/
  HEAD                      current branch ref
  index.json                staging area (path → blob hash)
  refs/heads/<branch>       one file per branch, contains commit hash
  objects/
    blobs/<hash>            file content, addressed by SHA-1
    trees/<hash>            JSON snapshot of the index at commit time
    commits/<hash>          JSON commit (tree, parents, message, timestamp)

Project structure

src/mgit/
  __main__.py       entry point and argument parsing
  utils.py          get_mgit_dir_path
  refs.py           HEAD and branch ref helpers
  index.py          staging area read/write
  ignore.py         .mgitignore support
  storage/
    blobs.py        SHA-1 hashing and unified diff
    trees.py        tree store/load
    commits.py      Commit dataclass, store/load
  commands/
    init.py         mgit init
    add.py          mgit add
    commit.py       mgit commit
    status.py       mgit status
    diff.py         mgit diff
    branch.py       mgit branch
    checkout.py     mgit checkout
    merge.py        mgit merge
    help.py         mgit help

About

A minimal Git-like version control system written in Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors