Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 1.28 KB

get-github-repo-size-with-bash.md

File metadata and controls

18 lines (12 loc) · 1.28 KB

Get Github Repository size with BASH

If you want to know the Github repo size before cloning it or for some other reason; you can use the Github REST API with jq and numfmt:

Bash command:

curl 'https://api.github.com/repos/git/git' | jq '.size' | numfmt --to=iec --from-unit=1024
  • Replace git\git with the user and the repository_name

Explanation:

  • We use the curl command to get the json data from the API
  • The json data is passed to the jq module and then we get the size property in which we are interested.
  • Then we use the numfmt to convert the size from integer to a human readable size. numfmt --to=iec command converts the bytes in integer format to a human readable size. Based on the Github REST API documentation, the size is returned in Kbs. Knowing this we inform the numfmt with --from-unit=1024 command that we are passing the integer in Kbs and not in bytes.

Got the numfmt command --from-unit=1024 here