Search code examples
pythongitpython

gitpython list all repositories


Folks, I keep having trouble finding documentation on how to list all git repositories for an organization using gitpython.
I would like to grab a list of all current repositories we have in bitbucket/github, but fail to find it in the docs. I've found pygithub3 example, but nothing for gitpython. Since I need to access bitbucket repos as well, pygithub3 wont work in my case.


Solution

  • gitpython is a library for manipulating the version-control software git itself and has little to do with online services like Github or Bitbucket. In order to interface either of those, you will need to use libraries like pygithub3 and python-bitbucket as both offer completely different APIs for retrieving organizations, let alone repositories themselves. gitpython will come in handy should you want to clone and manipulate a fork of a repository from one of these online services.

    Your hypothetical workflow might look something like this:

    1. Retrieve repositories of Github-hosted organization xyz-corp using pygithub3, or alternatively, the repositories of Bitbucket-hosted organization uvw-corp using python-bitbucket
    2. Clone the repositories locally using gitpython
    3. Manipulate the files
    4. Commit and push your changes back to the remote, Github-or-Bitbucket-hosted repository using gitpython