Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Estimate the size of a Git repository before cloning it

Tags:

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.

like image 589
PJ Bergeron Avatar asked Feb 23 '15 16:02

PJ Bergeron


People also ask

How do I find the size of a git repository?

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.

What is the recommended repository size by GitHub?

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.

How much space do we get on each git repository?

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.

How do I find the size of a bitbucket repository?

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".


1 Answers

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.

like image 133
jthill Avatar answered Oct 06 '22 08:10

jthill