Ben Chuanlong Du's Blog

It is never too late to learn.

Git Implementations and Bindings in Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

There are multiple Git implementations/bindings in Python: pygit2, Dulwich and GitPython .

Below is a simple comparison of the 3 packages.

pygit2 dulwich GitPython
Implementation bindings to libgit2 pure Python bindings …

Hands on GitPython

Tips and Traps

  1. GitPython is a wrapper around the git command. It requires the git command to be on the search path in order to work. Also, sometimes it is easier to call the git command via subprocess.run directly instead of using GitPython.

  2. The git command (and thus GitPython) accepts URLs both with and without the trailing .git