Is there any way to estimate the size of a public Git repository without having to clone it?
I'd like to use this information to make sure the repository is smaller than a certain size. If it's not, I don't want to clone it.
I know it can be done on Github but this repository is hosted on a dedicated server.
To find the size of your . git directory, use du – sh . git. You can use git count-objects -v to count the number of unpacked object files and disk space consumed by them.
We recommend repositories remain small, ideally less than 1 GB, and less than 5 GB is strongly recommended. Smaller repositories are faster to clone and easier to work with and maintain.
Every account using Git Large File Storage receives 1 GB of free storage and 1 GB a month of free bandwidth. If the bandwidth and storage quotas are not enough, you can choose to purchase an additional quota for Git LFS.
In Bitbucket Cloud, a repository admin can see the size under "Repository Details" under Settings. In Bitbucket Server too, you can view it under Settings > Repository Details after clicking on "Retrieve Size Details".
Short answer: "no."
If space is a concern at all, clone the repo to your largest available freespace and if it's dinky enough to put elsewhere moving it will be cheap.
A really brute-force way to get it: put this in e.g. your post-receive hook on the server
git for-each-ref refs/size | while read . . ref; do git update-ref --delete $ref; done
set -- $(du -sh .git/objects)
git update-ref refs/size/$1-as-of-$(date +%Y%m%dT%H%M%S%Z) HEAD
and you can just ls-remote for it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With