Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve the list of all GitHub repositories of a person?

People also ask

How do I find my git repository list?

You can get a list of any configured remote URLs with the command git remote -v . git remote -v because -v is for verbose. git remote gives a simple list of remotes (base, origin in this case). The -v option includes the url for both fetch and push operations of each remote.

How many GitHub repos exist?

There are over 128 million public repositories on GitHub.

Can I see how many people viewed my GitHub repo?

If your project is hosted on GitHub, you can view how many people land on your project and where they come from. From your project's page, click “Insights”, then “Traffic”. On this page, you can see: Total page views: Tells you how many times your project was viewed.


You can use the github api for this. Hitting https://api.github.com/users/USERNAME/repos will list public repositories for the user USERNAME.


Try the following curl command to list the repositories:

GHUSER=CHANGEME; curl "https://api.github.com/users/$GHUSER/repos?per_page=100" | grep -o 'git@[^"]*'

To list cloned URLs, run:

GHUSER=CHANGEME; curl -s "https://api.github.com/users/$GHUSER/repos?per_page=1000" | grep -w clone_url | grep -o '[^"]\+://.\+.git'

If it's private, you need to add your API key (access_token=GITHUB_API_TOKEN), for example:

curl "https://api.github.com/users/$GHUSER/repos?access_token=$GITHUB_API_TOKEN" | grep -w clone_url

If the user is organisation, use /orgs/:username/repos instead, to return all repositories.

To clone them, see: How to clone all repos at once from GitHub?

See also: How to download GitHub Release from private repo using command line


Use the Github API:

/users/:user/repos

This will give you all the user's public repositories. If you need to find out private repositories you will need to authenticate as the particular user. You can then use the REST call:

/user/repos

to find all the user's repos.

To do this in Python do something like:

USER='AUSER'
API_TOKEN='ATOKEN'
GIT_API_URL='https://api.github.com'

def get_api(url):
    try:
        request = urllib2.Request(GIT_API_URL + url)
        base64string = base64.encodestring('%s/token:%s' % (USER, API_TOKEN)).replace('\n', '')
        request.add_header("Authorization", "Basic %s" % base64string)
        result = urllib2.urlopen(request)
        result.close()
    except:
        print 'Failed to get api request from %s' % url

Where the url passed in to the function is the REST url as in the examples above. If you don't need to authenticate then simply modify the method to remove adding the Authorization header. You can then get any public api url using a simple GET request.


Here is a full spec for the repos API:

https://developer.github.com/v3/repos/#list-repositories-for-a-user

GET /users/:username/repos

Query String Parameters:

The first 5 are documented in the API link above. The parameters for page and per_page are documented elsewhere and are useful in a full description.

  • type (string): Can be one of all, owner, member. Default: owner
  • sort (string): Can be one of created, updated, pushed, full_name. Default: full_name
  • direction (string): Can be one of asc or desc. Default: asc when using full_name, otherwise desc
  • page (integer): Current page
  • per_page (integer): number of records per page

Since this is an HTTP GET API, in addition to cURL, you can try this out simply in the browser. For example:

https://api.github.com/users/grokify/repos?per_page=2&page=2