How can I see the size of a GitHub repository before cloning it?

Is there a way to see how big a Git repository is on GitHub before you decide to clone it?

This seems like a really obvious/basic statistic, but I can't find how to see it on GitHub at all.


There's a way to access this information through the GitHub API.

  • Syntax: GET /repos/:user/:repo
  • Example: https://api.github.com/repos/git/git

When retrieving information about a repository, a property named size is valued with the size of the whole repository (including all of its history), in kilobytes.

For instance, the Git repository weights around 124 MB. The size property of the returned JSON payload is valued to 124283.

Update

The size is indeed expressed in kilobytes based on the disk usage of the server-side bare repository. However, in order to avoid wasting too much space with repositories with a large network, GitHub relies on Git Alternates. In this configuration, calculating the disk usage against the bare repository doesn't account for the shared object store and thus returns an "incomplete" value through the API call.

This information has been given by GitHub support.


If you own the repository, you can find the exact size by opening your Account SettingsRepositories (https://github.com/settings/repositories), and the repository size is displayed next to its designation.

If you do not own the repository, you can fork it and then check the in the same place.

Note: You might be the owner of the organization that hosts multiple repositories and yet not have a role in a specific repository inside the organization. By default, even if you create a repository in the organization you own, you are not added to the repo and hence not see that repo in settings/repositories. So add yourself in the repository Setting(https://github.com/org-name/repo-name/settings) to see it in https://github.com/settings/repositories

Somewhat hacky: use the download as a zip file option, read the file size indicated and then cancel it.

I do not remember if downloading as a zip ever worked, but in any case, doing so now only downloads the currently selected branch with no history.