Determining the size of the .git for a GitHub repo, without cloning it

The GitHub logo, with an Octocat next to it

Every so often, I'll be doing work that needs to know how big a Git repo is.

Right now, I'm doing some work in Renovate around how we support large repos and/or monorepos, and have hit the same question - "how big is that repo's .git folder", which gives an important guide for the minimum disk requirement needed for that repo.

(I thought I'd already blogged about this, but it seems like I hadn't)

A more convenient method is to use the GitHub API to look up that metadata, without needing to go through the pain of cloning it - even bloblessly - where we can instead:

gh api /repos/renovatebot/renovate --jq .size
172111
# ~168M

Per the docs:

The size of the repository, in kilobytes. Size is calculated hourly. When a repository is initially created, the size is 0.

We can see that if we clone the repo, we get a fairly similar number:

% git clone https://github.com/renovatebot/renovate
% du --summarize --apparent-size --human-readable renovate/.git
177M
# and with everything checked out
% du -sh renovate
211M

We can also compare this to a --bare clone:

% git clone https://github.com/renovatebot/renovate --bare renovate-bare
% du -sh renovate-bare
176M

There's a slight difference that may be due to GitHub's server-side configuration, but it's good enough to go off of.

Some other useful repos to check against, as they're ones I consider when thinking about "large repos I can access":

% gh api /repos/backstage/backstage --jq .size
8774031
# ~8568MB
# ~8.4GB

% gh api /repos/elastic/kibana --jq .size
19091449
# ~18643M
# ~18.2G

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

This blog post is 100% human-written, and has nothing derived from LLMs (be it code, editorial support or prose).

Also on:

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.