在克隆之前估计Git存储库的大小 [英] Estimate the size of a Git repository before cloning it
问题描述
是否有任何方法可以估计公共Git存储库的大小而无需克隆它?
我想要使用这些信息确保存储库小于一定的大小。如果不是,我不想克隆它。
我知道它可以在Github上完成,但是此存储库托管在专用服务器上。 / b> 如果空间是一个问题,可以将回购克隆到最大可用的自由空间,如果它足够小,可以放到其他地方移动,它便宜。 一个真正的蛮力方式得到它:把它放在例如服务器上的post-receive钩子 ,您可以使用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 and you can just ls-remote for it. 这篇关于在克隆之前估计Git存储库的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
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
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