如何找出一个组织的所有Github存储库的大小

时间:2017-06-09 15:32:48

标签: git github repository github-api

我们正在将Github存储库移动到具有GitLab-Server的本地服务器上。我们将使用Jenkins-Server进行构建。

在此之前,我们想知道,两台机器上的硬盘驱动器有多大。

- > GitServer将需要磁盘空间用于回购 - > Jenkins-Server将需要磁盘空间用于构建

的repos +空间

因此:有没有办法找出我们所有存储库中有多少磁盘空间 - 不仅是实际文件大小,而且实际上是整个git存储库的大小?

我读到了API。 但是做了

curl -i -u <myUserName>  https://api.github.com/orgs/<organisationName>

我实际上可以接收元数据,但它似乎没有提供有关实际使用的磁盘空间的任何信息:

HTTP/1.1 200 OK
Server: GitHub.com
Date: Fri, 09 Jun 2017 15:09:07 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 1463
Status: 200 OK
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4980
X-RateLimit-Reset: 1497022865
Cache-Control: private, max-age=60, s-maxage=60
Vary: Accept, Authorization, Cookie, X-GitHub-OTP
ETag: "62fadd06b840f42f8bf9cb69450b9d1b"
Last-Modified: Tue, 30 May 2017 12:33:36 GMT
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'none'
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-Runtime-rack: 0.068430
X-GitHub-Request-Id: XXXX:XXXX:XXXXXXX:XXXXXXX:XXXXXXX

{
  "login": "XXXXXXXX",
  "id": XXXXXXXXX,
  "url": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "repos_url": "https://api.github.com/orgs/XXXXXXX/repos",
  "events_url": "https://api.github.com/orgs/XXXXXX/events",
  "hooks_url": "https://api.github.com/orgs/XXXXXX/hooks",
  "issues_url": "https://api.github.com/orgs/XXXXXX/issues",
  "members_url": "https://api.github.com/orgs/XXXXXX/members{/member}",
  "public_members_url": "https://api.github.com/orgs/XXXXXX/public_members{/member}",
  "avatar_url": "https://avatars1.githubusercontent.com/XXXXXX",
  "description": "XXXXXX",
  "name": "XXXXXX",
  "company": null,
  "blog": "XXXXXX",
  "location": "XXXXXX",
  "email": "XXXXXXXXXXXXXXXXXXXX",
  "has_organization_projects": true,
  "has_repository_projects": true,
  "public_repos": 0,
  "public_gists": 0,
  "followers": 0,
  "following": 0,
  "html_url": "https://github.com/XXXXXXXXXXXXXX",
  "created_at": "2016-09-14T11:30:47Z",
  "updated_at": "2017-05-30T12:33:36Z",
  "type": "Organization",
  "total_private_repos": 62,
  "owned_private_repos": 62,
  "private_gists": null,
  "disk_usage": null,
  "collaborators": null,
  "billing_email": null,
  "plan": {
    "name": "team",
    "space": 976562499,
    "private_repos": 99999,
    "filled_seats": 15,
    "seats": 15
  },
  "default_repository_permission": null,
  "members_can_create_repositories": true
}

有一个标记space但它似乎只是可用的最大空间而不是使用的。还有另一个标记disk_usage,但它是null

2 个答案:

答案 0 :(得分:1)

或许git clone --bare全部并检查磁盘上的大小?

答案 1 :(得分:0)

最后我还是用

解决了
git lfs clone --mirror RepoURL localRepoFolder
cd localRepoFolder
git-lfs fetch --all
du -s
#cleanup
cd ..
rm -rf localRepoFolder

针对循环中的每个存储库并汇总所有大小