How to Know the Size and Creation Date of GitHub Repositories

Published: Mar 3, 2018
3 min read
Last updated: Mar 26, 2020

Most often we'd like to know the size or creation date of public repositories out of curiosity before cloning or forking. Knowing the size will come in handy when we decide to pull a repository, if it's huge we can just download the desired files or browse on GitHub itself.

I agree there are plenty of browser extensions to the rescue. GitHub Repository Size & Github - Date of creation to name a few. The downside is all those are browser specific, in the sense you've to install different plugins for different browser.

github repository size and creation date bookmarklet

Those consume system memory and it may slow down the browser start up time. The solution must be browser independent. Also, you won't need the details of every single repository you come across.

You can use a bookmarklet for this purpose. Just drag and drop the following button to your bookmarks bar.

GitHub Repo Info

Now whenever you want to know the details of any repository, when it is open in the current tab of browser, just click the bookmark on the bookmarks bar. It'll display both the size and creation date of that repository. Just press ESC key or Enter key or press OK button to hide the alert.

Troubleshooting

If you don't find the bookmarks bar on your browser,
Chrome - Click on top right corner three dot menu → Bookmarks → Show bookmarks bar.
Firefox - Right click top right corner hamburger menu → Bookmarks Toolbar.

You may also like - How to get GitHub notifications on Slack.

Not working on Firefox

Sometimes due to a bug on Firefox, this bookmarklet won't work. In that case go to about:config and search for security.csp.enable and set it to false (simply you can double click the appropriate row).

Private & Organization Repositories

Without any changes you can use this bookmarklet for any public repositories, but to make it work for private or private organization repositories, you've to do some extra work. Because not all people are authorized to view private repository details using GitHub APIs.

Just go to GitHub tokens page, click Generate new token, give it a name, check repo and then scroll down and select Generate token.

github add new personal token page

The page will display a token, you have to copy the token. Now right click the bookmarklet and select Edit (on Firefox Properties), copy the whole URL (on Firefox Location) section, Paste it in a text editor of your choice. Remove the comments that wraps this piece of code xmlHttp.setRequestHeader('Authorization', 'token abc'); and replace abc with the token you copied from GitHub.

Now copy the whole text and paste it back in the URL section of the bookmarklet and save. After this step, you'll be able to get the details of private repositories too.

How it works

This bookmarklet is basically a JavaScript which runs when you click it. All it does is it fetches the repository information from GitHub using repository GET API and populates the result as an alert. To know what that API returns open below URL on your browser.

https://api.github.com/repos/git/git

You can replace first git with a username or organization name and second git with the repository name to get custom result. If that repository is a private or private organization one, you have to send authorization header in this format: Authorization: token <access_token>. Source code of the bookmarklet - GitHub Repository Size and Creation Date bookmarklet.

I have built an app to check the things that matter to you the most with a single click. If this interests you, you can give it a try on getradar.co.