Reputation: 875
Here's my query to the GitHub API
curl -i -u {user} https://api.github.com/orgs/{org}/repos?type=all
But this does not list all repos for this organization that I have access to. Specifically, it does not list repos in the organization that are part of a team that I am a member of.
If I were to query
curl -i -u {user} https://api.github.com/teams/{teamid}/repos
I would see the missing repos. If I were to navigate to github.com, I would see both private organization repos and my team repos next to each other on the same page. Is there a way to get all of these repos in the same API query?
Upvotes: 46
Views: 71821
Reputation: 1192
You can use the below command
gh repo list {organization-name}
before this login with below command
gh auth login
github.com/cli/cli
Upvotes: 52
Reputation: 41
Download the official gh cli, the github cli (https://cli.github.com/)
gh repo list $ORG -L $COUNT --json name --jq '.[].name'
Set $ORG equal to your organization name, and $COUNT to be the amount of Repos you want to list. (Set $COUNT equal to the amount of repos in the organization if you want to list them all)
Upvotes: 4
Reputation: 79
If you have gh
, the github cli (https://cli.github.com/) and jq
(https://stedolan.github.io/jq/) you can do this:
gh repo list $ORG -L $COUNT --json name | jq '.[].name' | tr -d '"'
where $ORG is your organization name and $COUNT is the max number of repos returned
Upvotes: 5
Reputation: 747
To add to original answer, below command can be used if there are many repositories and you wanted to fetch required number of repos. Without -L
flag it returns 30 items by default.
gh repo list <org> -L <#>
Upvotes: 9
Reputation: 105
Have you tried setting the "per_page"-attribute to "0"? I have seen some APIs using a default value of for example 20, but if you activately set it to 0, like ?per_page=0
you get all pages.
Upvotes: 0
Reputation: 107
curl -i -u "username":"password" https://your_git_url.com/organization_name | grep "codeRepository" | awk -F '"' '{print $6}'
Upvotes: 0
Reputation: 875
I apologize. It was listing all my repos...on subsequent pages. Learning about "page=" and "per_page=" was all I needed, and now I can see all of the repos I need.
Upvotes: 8