Estimate the size of a Git repository before cloning it

后端 未结 2 1975
-上瘾入骨i
-上瘾入骨i 2021-02-04 01:26

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 reposito

2条回答
  •  梦如初夏
    2021-02-04 02:06

    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.

提交回复
热议问题