在克隆之前估计Git存储库的大小 [英] Estimate the size of a Git repository before cloning it

查看:88
本文介绍了在克隆之前估计Git存储库的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何方法可以估计公共Git存储库的大小而无需克隆它?

我想要使用这些信息确保存储库小于一定的大小。如果不是,我不想克隆它。



我知道它可以在Github上完成,但是此存储库托管在专用服务器上。 / b> 如果空间是一个问题,可以将回购克隆到最大可用的自由空间,如果它足够小,可以放到其他地方移动,它便宜。

一个真正的蛮力方式得到它:把它放在例如服务器上的post-receive钩子

  git for-each-ref refs / size |同时阅读。 。 REF;做git update-ref --delete $ ref;完成
set - $(du -sh .git / objects)
git update-ref refs / size / $ 1-as-of - $(date +%Y%m%dT%H%M %S%Z)HEAD

,您可以使用ls-remote。


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.

解决方案

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.

这篇关于在克隆之前估计Git存储库的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆