Skip to content

Instantly share code, notes, and snippets.

Created March 30, 2019 12:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A basic pygithub3 example that shows how to get all the public and PRIVATE repos of a github user
#!/usr/bin/env python3
# This python script allows you to get all public and private repos of a given user (either by their name or by their OAuth token)
# For me, the intended use of this example is to use it backup all my repos to my machine (just in case :p)
# Usage:
# First install dependency using command: pip3 install pygithub3 --user
# Now copy paste your github token at line 15 as an argument (you CAN also use it like this: ....Github("my_github_username", "my_github_password")
# run this script like this: python3
# and the output should be, that it'll print all the clone urls for the repos a given user has.
# you can do a lot more stuff with this, just read the pygithub3 docs.
import pygithub3
def main():
repos_list = []
for repo in gh.get_user().get_repos():
if __name__ == '__main__':
Copy link

cyfrost commented Mar 30, 2019

This script at it's most basic level just prints the clone_url of all repos (including organization and the user's private repos as well).

A lot more can be done but this example intends to stay basic. Maybe you want to just do a git clone url or something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment