In this post, you will see two ways to find out the size of a GitHub repository before downloading or cloning it. Both methods will be able to help you find out the size of the GitHub repos in KB or in other higher formats with ease. One method is via GitHub’s own API and the other one uses a Chrome extension for the same thing.
If you are a GitHub user and often struggle with the size of a repository than these two methods are for you. Using any of these methods, you will not have to download or clone a repository first in order to determine its size. These two ways can help you save time in case you accidentally start cloning a repository which is large in size.
Method 1: Use GitHub API to Find size of a GitHub Repository before Downloading/Cloning
This is probably the easiest method out there that you can use. It does not require any extra tool or third-party app to let you find the size of a repo. Actually, GitHub has its own API and you can request all the raw data about any repository by making simple HTTP calls.
Using this method is actually very simple. You just need to modify the repository URL in order to get things done. You have to convert a repo URL in this format:
https://api.github.com/repos/{orgname/username}/{repo_name}
So, for instance consider this URL: https://github.com/ilovefreesw/AMPER
In API format, it will become: https://api.github.com/repos/ilovefreesw/AMPER
Now, you just paste this URL in the browser and hit enter. It will show JSON data and to format this data, you can use a JSON formatter extension. In the JSON response, you can search for the size field and its value is the actual size of the repository in Kilo Bytes.
This method will only work on public repositories. If you intend to find out the size of a private GitHub repository then you need to use this API URL format instead.
https://{username}:{api-token}@api.github.com/repos/{orgname/username}/{repo_name}
In this way, you can now make use of this simple trick involving GitHub API to find out the size of any GitHub repository in a few seconds. All you need is a correct repository name along with the organization name and the user’s name who created it.
Method 2: Use GitHub API to Find size of a GitHub Repository before Downloading/Cloning
The second method in my list to find size of a GitHub repo is through a Chrome extension. The name of this extension is GitHub Repository Size. And as the name indicates, it is what it does. It can help you identify the size of a GitHub repository automatically. And it is quite powerful as well because if you give it your GitHub access token then it will be able to tell you the size of private GitHub repository as well.
Basically, this extension modifies the interface of GitHub itself. On the main repository page, it adds the size attribute. You just install it from here and then go to any GitHub repository page. At the top side, you will see the size of the current repository in KB.
By default, it will only show you the size of public GitHub repositories. To see the size of the private repository that you own, you need to give it an access token. Click on its icon from the browser toolbar and then paste your token. From now on, it will be able to show you the size of the private repos too.
In this way, you can use this simple browser extension to quickly find out the size of any GitHub repository. You can use this method, if you don’t want to search the data into the huge JSON corpus. Just install it and forget about it.
Final thoughts:
If you are looking for ways to find somehow the size of a GitHub repository before cloning or downloading it then you are at the right place. Here I have mentioned two simple methods that you can use. One does not require any other tool or services. And the other one uses a simple Chrome extension. So, depending on which one you find easier to use, you can simply use that method.