Skip to content

Instantly share code, notes, and snippets.

@saru2020
Forked from dingzeyuli/check_github_repo_size
Created September 17, 2021 02:55
Show Gist options
  • Save saru2020/136c538c97b8521edcb5c73ea5d96b47 to your computer and use it in GitHub Desktop.
Save saru2020/136c538c97b8521edcb5c73ea5d96b47 to your computer and use it in GitHub Desktop.
Check the size of a github repo before downloading
# http://webapps.stackexchange.com/questions/39587/view-estimated-size-of-github-repository-before-cloning
# tested on macOS
echo https://github.com/torvalds/linux.git | perl -ne 'print $1 if m!([^/]+/[^/]+?)(?:\.git)?$!' | xargs -I{} curl -s -k https://api.github.com/repos/'{}' | grep size
# output:
# "size": 1746294,
@saru2020
Copy link
Author

saru2020 commented Sep 17, 2021

For private repositories:

curl -s -H "Authorization: token <GITHUB_TOKEN>" https://api.github.com/repos/torvalds/linux | jq '.size' | numfmt --to=iec --from-unit=1024

Result:
3.3G

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment