Is it possible to remote count object and size of git repository?
Assume that somewhere in the web exists public git repository. I want to clone it but firstly i need to be sure what is size of it (how much objects & kbytes like in git count-objects
)
Is there a way to do it?
Solution 1:
One little kludge you could use would be the following:
mkdir repo-name
cd repo-name
git init
git remote add origin <URL of remote>
git fetch origin
git fetch
displays feedback along these lines:
remote: Counting objects: 95815, done.
remote: Compressing objects: 100% (25006/25006), done.
remote: Total 95815 (delta 69568), reused 95445 (delta 69317)
Receiving objects: 100% (95815/95815), 18.48 MiB | 16.84 MiB/s, done.
...
The steps on the remote end generally happen pretty fast; it's the receiving step that can be time-consuming. It doesn't actually show the total size, but you can certainly watch it for a second, and if you see "1% ... 23.75 GiB" you know you're in trouble, and you can cancel it.
Solution 2:
[ update 21 Sep 2021 ]
It seems that the link will now be redirected to another URL, so we need to add -L
to curl to follow the redirection.
curl -sL https://api.github.com/repos/Marijnh/CodeMirror | grep size
[ Old answer ]
For github repository, it now offer API to check file size. It works!
This link: see-the-size-of-a-github-repo-before-cloning-it gave the answer
Command: (answer from @VMTrooper)
curl https://api.github.com/repos/$2/$3 | grep size
Example:
curl https://api.github.com/repos/Marijnh/CodeMirror | grep size
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5005 100 5005 0 0 2656 0 0:00:01 0:00:01 --:--:-- 2779
"size": 28589,
Solution 3:
Doesn't give the object count, but if you use Google Chrome browser and install this extension
It adds the repo size to the home page: