Rpj
Rpj

Reputation: 6110

Find all empty repositories in Github

How to find empty repositories in Github under a certain account, we have a large number of git repositories and would like to know if there is an empty repo without any branches

Upvotes: 5

Views: 806

Answers (1)

ArnabXD
ArnabXD

Reputation: 519

Check if the repository has no branches -

Method : GET

Endpoint : https://api.github.com/repos/{repoOwner}/{repoName}/branches

this returns an array of branch details .e.g:

  {
    "name": "main",
    "commit": {
    "commit": {
      "sha": "....",
      "URL": "..."
    },
    "protected": false
  },
  {
    "name": "v-2.0.0",
    "commit": {
      "sha": "....",
      "URL": "..."
    },
    "protected": false
  }
]

If there are no branches then it returns an empty array - []

Additionally, you can get the repository list using

Method: GET

Endpoint : https://api.github.com/users/{username}/repos

Official Docs by GitHub - Read Here

Upvotes: 5

Related Questions