The git clone command assumes everyone has unlimited fixed-rate Internet. I have no Internet.
Sometimes I’m on a friend’s measured rate uplink with a tight quota. So I cannot be blindly fetching a repository that blows copious amounts of quota.
Fuck surprises. They suck. How do I inform myself of the consequences of git clone before running it?
HTTP has a useful facility: the content-length: header. So this gives a way to get the size of a single web object before fetching:
curl -L --head "$url" | grep -i content-length
If git count-objects were sophisticated enough, it could perhaps theoretically get a tree of objects without their contents and perform the above header check on each object.
The only viable option is apparently to run git clone in a remote shell account just for the purpose of running git count-objects, then delete the clone and rerun the clone op locally if the size is acceptible.
Any better ideas?
2 Comments
SnoopSqueak@lemmy.today · 3 pts · 39d
Instead of git clone, initialize a new local repository, add the remote origin, and then
git fetch:https://stackoverflow.com/questions/2882620/is-it-possible-to-remote-count-object-and-size-of-git-repository
freedomPusher@sopuli.xyz · 2 pts · 39d
Thanks! That link is jailed in Cloudflare’s walled garden but this variant is reachable to everyone (in case someone else wants to follow this):
https://overflow.ocus.top/questions/2882620/is-it-possible-to-remote-count-object-and-size-of-git-repository
The
fetchoperation does not disclose the total before fetching, but it gives a way to monitor progress which is good enough in some situations. I wonder if the percentage can be trusted. If the percentage is accurate, then it must also know the total. But the ratio is not apparently based on size.Further down in your same article, there is a Github-specific way to get the size, which I tweaked to:
Perhaps the best generic answer (independent of Github) is further down the same page. This comment gives a codified way of doing what I was contemplating.
I appreciate the helpful link. Though I’m seeing a huge discrepency. E.g., for this repo, curl gives
34785(which is apparently in kilobytes) andgit count-objects -vHafter fetching gives about the same answer. Yet the repo is actually nearly double that size (~61 mb).