I was just wondering if it's possible to count the total number of empty repositories on GitHub.
If not for all users, can it be done for yourself?
I have tried the size:0
search, but it seems to return a lot of repositories which do contain data. Taking something like size:0..1
didn't help either.
If I try searching for the keyword empty
, but it doesn't cover all aspects.
I got a response from Brian Levine (GitHub)
That would be an interesting statistic. We don't have a simple way to do that right now. However, you might be able to use the GitHub API to get close. You could look through public repositories and compare "pushed_at" and "created_at" dates to see if there has been any activity. Additionally, you could find repositories with a "size" of 0. There's more information on how to find this information, and much more, right here:
http://developer.github.com/v3/repos/
You could:
for each repo, check the ones with a size equals to 0.
(The size seems to be in KB)
GET /repos/:owner/:repo
Note that an "empty" repo could still have at least one commit, when created with the default README.md
description file.
Actually, as the OP Aniket comments:
I explained the meaning of empty as: 0-1 commits, max 3 files:
.gitignore
README.md
LICENSE
(Note: README
is different from README.md
)
Another way is, for each repo, to look at the number of commits.
0 or 1 commit means probably an empty repo.
Update: GitHub confirms there is no current way to determine if a repo is "empty".
The closest way to do that would be:
You could look through public repositories and compare "pushed_at" and "created_at" dates to see if there has been any activity
To check if a repository is empty, look to see if it has any commits.
https://api.github.com/repos/:owner/:repo/commits?per_page=1
An empty repository will have a non-successful HTTP status and the content...
{
"message": "Git Repository is empty.",
"documentation_url": "https://developer.github.com/v3"
}
If it doesn't exist, you'll get a 404 and...
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3"
}
If it does exist, you'll get an HTTP 200 and one commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With