Overview / Install¶
GitPython is a python library used to interact with git repositories, high-level like git-porcelain, or low-level like git-plumbing.
It provides abstractions of git objects for easy access of repository data, and additionally allows you to access the git repository more directly using either a pure python implementation, or the faster, but more resource intensive git command implementation.
The object database implementation is optimized for handling large quantities of objects and large datasets, which is achieved by using low-level structures and data streaming.
Installing GitPython is easily done using pip. Assuming it is installed, just run the following from the command-line:
# pip install GitPython
This command will download the latest version of GitPython from the
Python Package Index and install it
to your system. More information about
pip and pypi can be found
Alternatively, you can install from the distribution using the
# python setup.py install
Leakage of System Resources¶
GitPython is not suited for long-running processes (like daemons) as it tends to leak system resources. It was written in a time where destructors (as implemented in the __del__ method) still ran deterministically.
In case you still want to use it in such a context, you will want to search the codebase for __del__ implementations and call these yourself when you see fit.
Another way assure proper cleanup of resources is to factor out GitPython into a separate process which can be dropped periodically.
GitPython’s git repo is available on GitHub, which can be browsed at:
and cloned using:
$ git clone https://github.com/gitpython-developers/GitPython git-python
Initialize all submodules to obtain the required dependencies with:
$ cd git-python $ git submodule update --init --recursive
Finally verify the installation by running unit tests:
$ python -m unittest
Questions and Answers¶
Please use stackoverflow for questions, and don’t forget to tag it with gitpython to assure the right people see the question in a timely manner.
The issue tracker is hosted by GitHub:
GitPython is licensed under the New BSD License. See the LICENSE file for more information.