PyGithub is a library for interacting with the GitHub API; it will not let you clone your repository or otherwise interact with a local git repository.

GitPython is a Python interface to git and can be used to clone a remote repository. In fact, there's an example of exactly that at the beginning of the tutorial to which you have linked.

That said, it's not clear from your question exactly what you hope to accomplish -- learning the git commandline interface is an important skill if you're going to be working with GitHub (or git in general). While you can probably perform many of the same tasks with GitPython, you are arguably going to be spending much of your time duplicating the existing functionality of the commandline tools.

Answer from larsks on Stack Overflow
🌐
PyPI
pypi.org › project › PyGithub
PyGithub · PyPI
PyGitHub is a Python library to access the GitHub REST API.
      » pip install PyGithub
    
Published   Mar 22, 2026
Version   2.9.0
🌐
Wayfair-incubator
wayfair-incubator.github.io › pygitops
pygitops Documentation
Best of all, it works extremely well with GitPython as well as PyGithub!
🌐
Martin Heinz
martinheinz.dev › blog › 25
All the Things You Can Do With GitHub API and Python | Martin Heinz | Personal Website & Blog
June 15, 2020 - In both cases we start by taking GitHub token from environment variable. Next, in the example with using PyGitHub we use the token to create instance of GitHub class, which is then used to get repository and query its issues in open state.
🌐
Medium
zchelseal.medium.com › automate-your-git-workflow-with-gitpython-3320e833c4e2
Automate Your Git Workflow with GitPython | by Chelsea Liu | Medium
April 13, 2021 - There are other ways to create ... use the PyGithub library to authenticate with a GitHub token and publish a pull request on behalf of whichever account this token belongs to. I did not experiment with this option as it would introduce more steps than simply clicking on a link. The full GitPython documentation ...
🌐
GitHub
github.com › PyGithub › PyGithub
GitHub - PyGithub/PyGithub: Typed interactions with the GitHub API v3 · GitHub
PyGitHub is a Python library to access the GitHub REST API.
Starred by 7.7K users
Forked by 1.9K users
Languages   Python 99.6% | Shell 0.4%
Find elsewhere
🌐
Reddit
reddit.com › r/python › pygithub vs github3py which one is a safer bet for the future?
r/Python on Reddit: PyGithub vs github3py which one is a safer bet for the future?
August 17, 2020 - I am wondering which python github api library would be a better future bet, one that is more likely to be actively maintained. So far I identified…
🌐
Medium
medium.com › @dhani281 › comparing-and-merging-git-branches-using-python-4e43fcfd3c5d
Comparing and Merging Git branches using Python | by Dhani Sebastian | Medium
May 27, 2023 - GitHub, one of the most popular version control platforms, provides powerful features for branch management. Comparing and merging branches are common tasks when incorporating changes into the main branch. In this tutorial, we will explore how to compare and merge two branches in a GitHub repository using the PyGithub library and Anaconda.
🌐
GitHub
github.com › iterative › dvc › issues › 2215
dvc: consider switching from GitPython · Issue #2215 · iterative/dvc
July 2, 2019 - GitPython causes constant headache and considerable time loss investigating and fixing issues on windows with file not closed and processes not terminated soon enough. We have several places in our code where we were forced to use retrie...
Author   Suor
🌐
GitHub
github.com › gitpython-developers › GitPython
GitHub - gitpython-developers/GitPython: GitPython is a python library used to interact with Git repositories. · GitHub
GitPython is a python library used to interact with Git repositories. - gitpython-developers/GitPython
Starred by 5.1K users
Forked by 968 users
Languages   Python
🌐
Snyk
snyk.io › advisor › python packages › pygithub
PyGithub - Python Package Health Analysis | Snyk
August 21, 2021 - Learn more about PyGithub: package health score, popularity, security, maintenance, versions and more.
🌐
Snyk
snyk.io › advisor › python packages › gitpython
GitPython - Python Package Health Analysis | Snyk
March 12, 2023 - GitPython · v3.1.46 · Latest version published 1 month ago · License: BSD-3-Clause · PyPI · GitHub · Copy · Snyk scans all the packages in your projects for vulnerabilities and provides automated fix advice Get started free · 91 / 100 · security · No known security issues · popularity · Key ecosystem project · maintenance · Healthy · community · Sustainable · dulwich · 91 · pygit2 · 88 · PyGithub ·
🌐
Reddit
reddit.com › r/learnprogramming › how can i write a test for code that creates a git branch and makes a pull request, without actually doing either?
r/learnprogramming on Reddit: How can I write a test for code that creates a git branch and makes a pull request, without actually doing either?
July 24, 2020 -

I am using the python library pygithub to automatically create new branches and pull requests when certain files are updated. However, I am not sure how I would go about writing unit tests for this. I have a function that creates the branch and one that makes the pull request. I have tried looking at the pygithub tests for inspiration but I wasn't able to gain insight.

This would be very easy to test if I could simply allow pull requests and branches to be made, but I want to see if there is a way to do this without actually creating them. I looked into mocking objects, but I couldn't see how I that would actually be a real test since I am basically telling the objects what to do anyway.

How should I approach this problem? Is mocking even the right approach, or do I really need to create the branches and pull requests and delete them after?

🌐
Medium
devopslearning.medium.com › day-13-101-days-of-devops-github-api-using-python-and-pygithub-module-c1bcbaaeada7
Day 13–101 Days of DevOps — GitHub API using Python and PyGithub Module | by Prashant Lakhera | Medium
July 16, 2021 - Day 13–101 Days of DevOps — GitHub API using Python and PyGithub Module Welcome to Day 13 of 101 Days of DevOps. The topic for today is GitHub API using Python and using PyGithub Module. To view …
🌐
Readthedocs
gitpython.readthedocs.io › en › stable › tutorial.html
GitPython Tutorial — GitPython 3.1.46 documentation
Submodules can be conveniently handled using the methods provided by GitPython, and as an added benefit, GitPython provides functionality which behave smarter and less error prone than its original c-git implementation, that is GitPython tries hard to keep your repository consistent when updating submodules recursively or adjusting the existing configuration.
🌐
Libhunt
python.libhunt.com › pygithub-alternatives
PyGitHub Alternatives - Python Third-party APIs | LibHunt
January 18, 2026 - PyGitHub is a Python library to access the GitHub API v3 and Github Enterprise API v3.