在你决定克隆它之前,有没有办法看看GitHub上的Git存储库有多大?
这似乎是一个非常明显/基本的统计数据,但我根本找不到如何在GitHub上看到它。
在你决定克隆它之前,有没有办法看看GitHub上的Git存储库有多大?
这似乎是一个非常明显/基本的统计数据,但我根本找不到如何在GitHub上看到它。
当前回答
如果您试图找出您自己的存储库的大小。
你所要做的就是去GitHub设置存储库,你可以在浏览器中看到所有的大小,不需要额外的工作。
https://github.com/settings/repositories
其他回答
@larowlan很棒的示例代码。在新的GitHub API V3中,curl语句需要更新。此外,不再需要登录:
curl https://api.github.com/repos/$2/$3 2> /dev/null | grep size | tr -dc '[:digit:]'
例如:
curl https://api.github.com/repos/dotnet/roslyn 2> /dev/null | grep size | tr -dc '[:digit:]'
返回931668 (KB),几乎是GB。
私有回购需要身份验证。一种方法是使用GitHub个人访问令牌:
curl -u myusername:$PERSONAL_ACCESS_TOKEN https://api.github.com/repos/$2/$3 2> /dev/null | grep size | tr -dc '[:digit:]'
如果你已经安装了官方的GitHub CLI,你可以执行以下操作:
gh api repos/<org>/<repo> --jq '.size'
我想它的单位是kb。
如果您试图找出您自己的存储库的大小。
你所要做的就是去GitHub设置存储库,你可以在浏览器中看到所有的大小,不需要额外的工作。
https://github.com/settings/repositories
在浏览器中,使用JavaScript,因为Github API启用了CORS:
fetch(“https://api.github.com/repos/webdev23/source_control_sentry”) .then(v => v.json()).then((v) => { console.log(v['size'] + 'KB') } )
你可以使用Github API
下面是Python示例:
import requests
if __name__ == '__main__':
base_api_url = 'https://api.github.com/repos'
git_repository_url = 'https://github.com/garysieling/wikipedia-categorization.git'
github_username, repository_name = git_repository_url[:-4].split('/')[-2:] # garysieling and wikipedia-categorization
res = requests.get(f'{base_api_url}/{github_username}/{repository_name}')
repository_size = res.json().get('size')
print(repository_size)