Is there any way to see how big a git repo is on github before you decide to clone it? This seems like a really obvious/basic statistic but I can't find how to see it on github at all.
-
2possible duplicate of Is it possible to remote count object and size of of git repository? – kennytm Dec 27 '11 at 15:56
-
3@KennyTM very similar question, yes, but this is specific to github rather than any method using only the git protocol. – jhabbott Dec 27 '11 at 16:03
-
1FYI, check out this chrome extension which automatically adds repository size to GitHub's repository summary github.com/harshjv/github-repo-size. UPDATE: added this as an answer – Harsh Vakharia Aug 3 '16 at 19:40
There's a way to access this information through the GitHub API.
- syntax:
/repos/:user/:repo [GET] - example: https://api.github.com/repos/git/git
When retrieving information about a repository, a property named size is valued with the size of the whole repository (including all of its history), in kilobytes.
For instance, the Git repository weights around 40Mb. The size property of the returned JSON payload is valued to 40764.
Update:
The size is indeed expressed in kilobytes based on the disk usage of the server -side bare repository. However, in order to avoid to waste too much space with repositories with a large network, GitHub relies on Git Alternates. In this configuration, calculating the disk usage against the bare repository doesn't account for the shared object store and thus returns an "incomplete" value through the API call.
This information has been given by the GitHub support.
-
-
8Isn't the size in MB now -> It's not that clear, it looks like it depends on the repo being queried... Small repos expose size in bytes, large ones in megabytes. I've opened an issue at GitHub support. I'll update the answer as soon as the issue is closed. – nulltoken Jan 14 '13 at 18:57
-
4This doesn't seem to work for private repos. Am I missing something? Thanks! – nroose Jan 17 '14 at 21:42
-
9@nroose Try
$ curl -u "{:username}" https://api.github.com/repos/{:organization}/{:repository}. See developer.github.com/v3/#authentication – nulltoken Feb 7 '14 at 7:09 -
1
If you use Google Chrome browser you can install the GitHub Repository Size extension.
Repo here: https://github.com/harshjv/github-repo-size
-
-
2
-
2@BaneeIshaqueK its not the same but it does show you the repo size check it here – Syed Shamikh Shabbir Dec 2 '17 at 16:22
-
-
If you own the repo, you can find the exact size by opening your Account Settings > Repositories, and the repo size is displayed next to its designation.
If you do not own the repository, you can fork it and then check the in the same place.
Somewhat hacky: use the download as a zip file option, read the file size indicated and then cancel it.
I do not remember if downloading as a zip ever worked, but in any case, doing so now only downloads the currently selected branch with no history.
-
Shouldn't one take into account the zip compression? Source code and text files can be compressed upto about 60% I think. – ffledgling Feb 17 '13 at 21:14
-
I am unaware of a way to check the compression ratio of the zip without completing the download. Of course you could complete the download and then check the compression ratio. However, at that point, you might as well unzip and check the repo size directly. It really depends on how accurate you need to be. And if you can afford to download the repo to check. – CoatedMoose Sep 16 '13 at 5:48
-
I could not find it in
Settings > Repositories, but instead found the repo size underAccount Settings > Repositoriesoff of your git home page. Of course, this only works with repos that you own (or fork). – modulitos Jun 18 '14 at 18:44 -
Organizations' account settings do not appear to show repo size, so it is only if you own a repo as a user and not as an organization? – Bennett Brown Oct 31 '14 at 15:20
-
2The size of the zip file is no indication at all of the actual repository size: 1) it only includes a snapshot of the repository at a given revision with no history and 2) Git repositories are stored as pack files which are compressed, do not store duplicates etc. – kynan Oct 8 '15 at 22:50
To summarize @larowlan, @VMTrooper, and @vahid chakoshy solutions:
#!/usr/bin/env bash
if [ "$#" -eq 2 ]; then
echo "$(echo "scale=2; $(curl https://api.github.com/repos/$1/$2 2>/dev/null \
| grep size | head -1 | tr -dc '[:digit:]') / 1024" | bc)MB"
elif [ "$#" -eq 3 ] && [ "$1" == "-z" ]; then
# For some reason Content-Length header is returned only on second try
curl -I https://codeload.github.com/$2/$3/zip/master &>/dev/null
echo "$(echo "scale=2; $(curl -I https://codeload.github.com/$2/$3/zip/master \
2>/dev/null | grep Content-Length | cut -d' ' -f2 | tr -d '\r') / 1024 / 1024" \
| bc)MB"
else
printf "Usage: $(basename $0) [-z] OWNER REPO\n\n"
printf "Get github repository size or, optionally [-z], the size of the zipped\n"
printf "master branch (`Download ZIP` link on repo page).\n"
exit 1
fi
@larowlan great sample code. With the new GitHub API V3, the curl statement needs to be updated. Also, the login is no longer required:
curl https://api.github.com/repos/$2/$3 2> /dev/null | grep size | tr -dc '[:digit:]'
-
3This doesn't seem to work for private repos. Is there something I am missing? Thanks! – nroose Jan 17 '14 at 21:42
To do this with curl (sudo apt-get curl) and json pretty (sudo gem install jsonpretty json)
curl -u "YOURGITHUBUSERNAME" http://github.com/api/v2/json/repos/show/OWNER/REPO |
jsonpretty
replace YOURGITHUBUSERNAME with your git hub username (go figure). replace OWNER with the repo owner's git username replace REPO with the repo name.
Or as a nice bash script (paste this in a file named gitrepo-info)
#!/bin/bash
if [ $# -ne 3 ]
then
echo "Usage: gitrepo-info <username> <owner> <repo>"
exit 65
fi
curl -u "$1" http://github.com/api/v2/json/repos/show/$2/$3|jsonpretty
use like so
gitrepo-info larowlan pisi reel
This will give me info on the pisi/reel repo on github.
protected by eyllanesc Mar 17 at 6:41
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
