🌐
GitHub
github.com › gitpython-developers › GitPython
GitHub - gitpython-developers/GitPython: GitPython is a python library used to interact with Git repositories. · GitHub
GitPython and its required package dependencies can be installed in any of the following ways, all of which should typically be done in a virtual environment. ... git clone https://github.com/gitpython-developers/GitPython cd GitPython ./init-tests-after-clone.sh
Starred by 5.1K users
Forked by 968 users
Languages   Python
🌐
Readthedocs
gitpython.readthedocs.io › en › stable › tutorial.html
GitPython Tutorial — GitPython 3.1.46 documentation
# Create a new submodule and check it out on the spot, setup to track master # branch of `bare_repo`. As our GitPython repository has submodules already that # point to GitHub, make sure we don't interact with them.
🌐
GitHub
gist.github.com › plembo › a786ce2851cec61ac3a051fcaf3ccdab
Clone git repo using GitPython · GitHub
Clone git repo using GitPython. GitHub Gist: instantly share code, notes, and snippets.
🌐
Readthedocs
gitpython.readthedocs.io
GitPython Documentation — GitPython 3.1.46 documentation
GitPython Documentation · View page source · Overview / Install · Requirements · Installing GitPython · Limitations · Getting Started · API Reference · Source Code · Questions and Answers · Issue Tracker · License Information · GitPython Quick Start Tutorial ·
🌐
GitHub
github.com › gitpython-developers › GitPython › releases
Releases · gitpython-developers/GitPython
January 1, 2026 - GitPython is a python library used to interact with Git repositories. - Releases · gitpython-developers/GitPython
Author   gitpython-developers
🌐
Blue Book
lyz-code.github.io › blue-book › coding › python › gitpython
GitPython - The Blue Book
GitPython is a python library used to interact with git repositories, high-level like git-porcelain, or low-level like git-plumbing.
🌐
GitHub
github.com › gitpython-developers › GitPython › blob › main › git › repo › base.py
GitPython/git/repo/base.py at main · gitpython-developers/GitPython
GitPython is a python library used to interact with Git repositories. - GitPython/git/repo/base.py at main · gitpython-developers/GitPython
Author   gitpython-developers
🌐
Medium
zchelseal.medium.com › automate-your-git-workflow-with-gitpython-3320e833c4e2
Automate Your Git Workflow with GitPython | by Chelsea Liu | Medium
April 13, 2021 - Specifically for any local git repository (whose origin points to some project on GitHub), we wanted to script-ify the following: create a new branch off prod, make some commits, push these, and make a pull request. This sounded like a simple enough task (and it turned out so thanks to GitPython), ...
Find elsewhere
🌐
Full Stack Python
fullstackpython.com › blog › first-steps-gitpython.html
First Steps with GitPython - Full Stack Python
November 30, 2017 - Clone a repository you want to work with to your local system. If you don't have a specific one in mind use the open source Full Stack Python Git repository that is hosted on GitHub...
🌐
GitHub
github.com › gitpython-developers
gitpython-developers · GitHub
gitpython-developers has 8 repositories available. Follow their code on GitHub.
🌐
PyPI
pypi.org › project › GitPython
GitPython · PyPI
GitPython and its required package dependencies can be installed in any of the following ways, all of which should typically be done in a virtual environment. ... git clone https://github.com/gitpython-developers/GitPython cd GitPython ./init-tests-after-clone.sh
      » pip install GitPython
    
Published   Jan 01, 2026
Version   3.1.46
🌐
PyPI
pypi.org › project › GitPython › 0.3.2
GitPython
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Readthedocs
gitpython.readthedocs.io › en › stable › quickstart.html
GitPython Quick Start Tutorial — GitPython 3.1.46 documentation
# $ git clone <url> <local_dir> repo_url = "https://github.com/gitpython-developers/QuickStartTutorialFiles.git" repo = Repo.clone_from(repo_url, local_dir)
🌐
PDX
web.pdx.edu › ~gjay › teaching › mth271_2020 › html › 03_Working_with_git.html
Git Repo class in python
In particular, executing this notebook will pull the updated data from GitHub and place it in a location you specify (below). If you want to know more about git, there are many resources online, such as the Git Handbook. The most common way to fetch materials from a remote repository is using git's command line tools, but for our purposes, the python code in this notebook will suffice. We shall use the python module gitpython to work with git.
🌐
DevDungeon
devdungeon.com › content › working-git-repositories-python
Working with Git Repositories in Python | DevDungeon
March 17, 2020 - The [GitPython](https://gitpython.readthedocs.io/) project allows you to work in Python with Git repositories. In this guide we'll look at some basic operations like: - Initializing a repo - Cloning a repo - Adding and committing - Pushing and ...
Top answer
1 of 11
136

While this question was asked a while ago and I don't know the state of the libraries at that point, it is worth mentioning for searchers that GitPython does a good job of abstracting the command line tools so that you don't need to use subprocess. There are some useful built in abstractions that you can use, but for everything else you can do things like:

import git
repo = git.Repo( '/home/me/repodir' )
print repo.git.status()
# checkout and track a remote branch
print repo.git.checkout( 'origin/somebranch', b='somebranch' )
# add a file
print repo.git.add( 'somefile' )
# commit
print repo.git.commit( m='my commit message' )
# now we are one commit ahead
print repo.git.status()

Everything else in GitPython just makes it easier to navigate. I'm fairly well satisfied with this library and appreciate that it is a wrapper on the underlying git tools.

UPDATE: I've switched to using the sh module for not just git but most commandline utilities I need in python. To replicate the above I would do this instead:

import sh
git = sh.git.bake(_cwd='/home/me/repodir')
print git.status()
# checkout and track a remote branch
print git.checkout('-b', 'somebranch')
# add a file
print git.add('somefile')
# commit
print git.commit(m='my commit message')
# now we are one commit ahead
print git.status()
2 of 11
87

I thought I would answer my own question, since I'm taking a different path than suggested in the answers. Nonetheless, thanks to those who answered.

First, a brief synopsis of my experiences with GitPython, PyGit, and Dulwich:

  • GitPython: After downloading, I got this imported and the appropriate object initialized. However, trying to do what was suggested in the tutorial led to errors. Lacking more documentation, I turned elsewhere.
  • PyGit: This would not even import, and I could find no documentation.
  • Dulwich: Seems to be the most promising (at least for what I wanted and saw). I made some progress with it, more than with GitPython, since its egg comes with Python source. However, after a while, I decided it may just be easier to try what I did.

Also, StGit looks interesting, but I would need the functionality extracted into a separate module and do not want wait for that to happen right now.

In (much) less time than I spent trying to get the three modules above working, I managed to get git commands working via the subprocess module, e.g.

def gitAdd(fileName, repoDir):
    cmd = ['git', 'add', fileName]
    p = subprocess.Popen(cmd, cwd=repoDir)
    p.wait()

gitAdd('exampleFile.txt', '/usr/local/example_git_repo_dir')

This isn't fully incorporated into my program yet, but I'm not anticipating a problem, except maybe speed (since I'll be processing hundreds or even thousands of files at times).

Maybe I just didn't have the patience to get things going with Dulwich or GitPython. That said, I'm hopeful the modules will get more development and be more useful soon.

🌐
LinuxConfig
linuxconfig.org › home › how to manage git repositories with python
Manage Git Repositories with Python: GitPython Guide
May 27, 2022 - Until now we saw how to manage a local repository with the GitPython library; now, let’s see how to clone a repository. To clone a repository we have to use the clone_from method of the Repo class. The method takes the URL of the repository to be cloned as first argument, and the local filesystem path where it should be cloned, as second: repository = Repo.clone_from('https://github...
🌐
GitHub
github.com › topics › gitpython
gitpython · GitHub Topics · GitHub
A sample program for repository mining using GitPython.