The easy way is to use one of the utilities provided by Python's setuptools. If you don't have setuptools, you can install them with:

sudo apt-get install python-setuptools

...or with:

sudo yum install python-setuptools

... depending on your platform. You can then install GitPython with:

sudo easy_install GitPython

After that, it will be available for you to import and use:

import git


Initialize a Repository Object

If you have a local directory that has already been initialized as a Git repository (hint: it should contain a .git subdirectory), then you can simply create an object of it:

import git
repo = git.Repo('/home/marios/repositories/test-repo')

See Also