Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 792
jhabbott Avatar asked Dec 27 '11 15:12

jhabbott


People also ask

What is the difference between cloning and downloading from GitHub?

When you download the repo it just gives you all the source files with no . git so you dont have the repo. When you clone you get a copy of the history and it is a functional git repo.

Can people see when you clone a repository?

Can the owner of the repo see when someone clones it? No, they cannot. If I go to one of your repositories and clone it to my local hard drive, the owner will not be able to view that activity.

Does git clone copy the entire repository?

git clone is primarily used to point to an existing repo and make a clone or copy of that repo at in a new directory, at another location. The original repository can be located on the local filesystem or on remote machine accessible supported protocols. The git clone command copies an existing Git repository.


1 Answers

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.

like image 176
nulltoken Avatar answered Sep 17 '22 12:09

nulltoken