有次在克隆github项目的时候突然想知道项目有多大,发现好像没有什么直接的方式的可以看到,搜索了一番主要有两种方式:安装浏览器插件,使用GitHub API
- 安装浏览器插件
- Chrome插件:https://github.com/harshjv/github-repo-size
图片来自该gitnub项目的介绍 - Firefox插件:https://addons.mozilla.org/en-US/firefox/addon/github-repo-size/
- 使用GitHub API
直接在浏览器地址栏输入https://api.github.com/repos/organization/repository
其中organization
替换为项目的所有者(组织),repository
替换为项目的名称`
返回的页面是描述这个项目的JSON数据,其中的size指的就是项目的大小,单位为kB(千字节)
git组织的git项目:https://api.github.com/repos/git/git
北京大学的gStore项目:https://api.github.com/repos/pkumod/gStore
{
"id": 26917250,
"node_id": "MDEwOlJlcG9zaXRvcnkyNjkxNzI1MA==",
"name": "gStore",
"full_name": "pkumod/gStore",
"private": false,
"owner": {
"login": "pkumod",
"id": 42833321,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQyODMzMzIx",
"avatar_url": "https://avatars2.githubusercontent.com/u/42833321?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/pkumod",
"html_url": "https://github.com/pkumod",
"followers_url": "https://api.github.com/users/pkumod/followers",
"following_url": "https://api.github.com/users/pkumod/following{/other_user}",
"gists_url": "https://api.github.com/users/pkumod/gists{/gist_id}",
"starred_url": "https://api.github.com/users/pkumod/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/pkumod/subscriptions",
"organizations_url": "https://api.github.com/users/pkumod/orgs",
"repos_url": "https://api.github.com/users/pkumod/repos",
"events_url": "https://api.github.com/users/pkumod/events{/privacy}",
"received_events_url": "https://api.github.com/users/pkumod/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/pkumod/gStore",
"description": "gStore - a graph based RDF triple store.",
"fork": false,
"url": "https://api.github.com/repos/pkumod/gStore",
"forks_url": "https://api.github.com/repos/pkumod/gStore/forks",
"keys_url": "https://api.github.com/repos/pkumod/gStore/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/pkumod/gStore/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/pkumod/gStore/teams",
"hooks_url": "https://api.github.com/repos/pkumod/gStore/hooks",
"issue_events_url": "https://api.github.com/repos/pkumod/gStore/issues/events{/number}",
"events_url": "https://api.github.com/repos/pkumod/gStore/events",
"assignees_url": "https://api.github.com/repos/pkumod/gStore/assignees{/user}",
"branches_url": "https://api.github.com/repos/pkumod/gStore/branches{/branch}",
"tags_url": "https://api.github.com/repos/pkumod/gStore/tags",
"blobs_url": "https://api.github.com/repos/pkumod/gStore/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/pkumod/gStore/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/pkumod/gStore/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/pkumod/gStore/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/pkumod/gStore/statuses/{sha}",
"languages_url": "https://api.github.com/repos/pkumod/gStore/languages",
"stargazers_url": "https://api.github.com/repos/pkumod/gStore/stargazers",
"contributors_url": "https://api.github.com/repos/pkumod/gStore/contributors",
"subscribers_url": "https://api.github.com/repos/pkumod/gStore/subscribers",
"subscription_url": "https://api.github.com/repos/pkumod/gStore/subscription",
"commits_url": "https://api.github.com/repos/pkumod/gStore/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/pkumod/gStore/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/pkumod/gStore/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/pkumod/gStore/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/pkumod/gStore/contents/{+path}",
"compare_url": "https://api.github.com/repos/pkumod/gStore/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/pkumod/gStore/merges",
"archive_url": "https://api.github.com/repos/pkumod/gStore/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/pkumod/gStore/downloads",
"issues_url": "https://api.github.com/repos/pkumod/gStore/issues{/number}",
"pulls_url": "https://api.github.com/repos/pkumod/gStore/pulls{/number}",
"milestones_url": "https://api.github.com/repos/pkumod/gStore/milestones{/number}",
"notifications_url": "https://api.github.com/repos/pkumod/gStore/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/pkumod/gStore/labels{/name}",
"releases_url": "https://api.github.com/repos/pkumod/gStore/releases{/id}",
"deployments_url": "https://api.github.com/repos/pkumod/gStore/deployments",
"created_at": "2014-11-20T14:59:01Z",
"updated_at": "2018-12-18T01:14:43Z",
"pushed_at": "2018-12-15T11:12:42Z",
"git_url": "git://github.com/pkumod/gStore.git",
"ssh_url": "git@github.com:pkumod/gStore.git",
"clone_url": "https://github.com/pkumod/gStore.git",
"svn_url": "https://github.com/pkumod/gStore",
"homepage": "http://www.icst.pku.edu.cn/intro/leizou/projects/gStore.htm",
"size": 56946,
"stargazers_count": 164,
"watchers_count": 164,
"language": "C++",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 90,
"mirror_url": null,
"archived": false,
"open_issues_count": 0,
"license": {
"key": "bsd-3-clause",
"name": "BSD 3-Clause \"New\" or \"Revised\" License",
"spdx_id": "BSD-3-Clause",
"url": "https://api.github.com/licenses/bsd-3-clause",
"node_id": "MDc6TGljZW5zZTU="
},
"forks": 90,
"open_issues": 0,
"watchers": 164,
"default_branch": "master",
"organization": {
"login": "pkumod",
"id": 42833321,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQyODMzMzIx",
"avatar_url": "https://avatars2.githubusercontent.com/u/42833321?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/pkumod",
"html_url": "https://github.com/pkumod",
"followers_url": "https://api.github.com/users/pkumod/followers",
"following_url": "https://api.github.com/users/pkumod/following{/other_user}",
"gists_url": "https://api.github.com/users/pkumod/gists{/gist_id}",
"starred_url": "https://api.github.com/users/pkumod/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/pkumod/subscriptions",
"organizations_url": "https://api.github.com/users/pkumod/orgs",
"repos_url": "https://api.github.com/users/pkumod/repos",
"events_url": "https://api.github.com/users/pkumod/events{/privacy}",
"received_events_url": "https://api.github.com/users/pkumod/received_events",
"type": "Organization",
"site_admin": false
},
"network_count": 90,
"subscribers_count": 34
}
总结
使用浏览器插件更直观更方便,只需要安装插件
使用GitHub API的方式更简单,有人可能不喜欢安装那么多插件,比如我,不过需要稍微记一下格式
参考:
在克隆它之前看到github仓库的大小?- codeday.me
see the size of a github repo before cloning it - StackOverflow
网友评论