447

クローンを作成する前に、GitHub上のGitリポジトリの大きさを確認する方法はありますか?

これは本当に明白で基本的な統計のように見えますが、GitHubでそれを確認する方法をまったく見つけることができません。

4

11 に答える 11

181

リポジトリを所有している場合は、アカウント設定リポジトリ( https://github.com/settings/repositories ) を開いて正確なサイズを確認できます。リポジトリ サイズは指定の横に表示されます。

リポジトリを所有していない場合は、フォークして同じ場所でチェックできます。

注:複数のリポジトリをホストしている組織の所有者であるにもかかわらず、組織内の特定のリポジトリで役割を持っていない場合があります。デフォルトでは、自分が所有する組織にリポジトリを作成しても、リポジトリに追加されないため、そのリポジトリは表示されませんsettings/repositories。そのため、リポジトリ Setting( https://github.com/org-name/repo-name/settings) に自分自身を追加して、https://github.com/settings/repositories

ややハック:download as a zip fileオプションを使用し、指定されたファイル サイズを読み取ってからキャンセルします。

zip としてのダウンロードが機能したかどうかは覚えていませんが、いずれにしても、現在選択されているブランチのみが履歴なしでダウンロードされます。

于 2012-06-19T02:55:09.110 に答える
34

@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:]'

(KB 単位) を返します931668。これはほぼ GB です。

プライベート リポジトリには認証が必要です。1 つの方法は、GitHub Personal Access トークンを使用することです。

curl -u myusername:$PERSONAL_ACCESS_TOKEN https://api.github.com/repos/$2/$3 2> /dev/null | grep size | tr -dc '[:digit:]'
于 2013-09-23T23:11:19.613 に答える
11

curl (sudo apt-get curl) と json pretty (sudo gem install jsonpretty json) でこれを行うには:

curl -u "YOURGITHUBUSERNAME" http://github.com/api/v2/json/repos/show/OWNER/REPOSITORY |
  jsonpretty

YOURGITHUBUSERNAME を GitHub ユーザー名に置き換えます (図を参照)。

OWNER をリポジトリ所有者の Git ユーザー名に置き換えます。REPOSITORY をリポジトリ名に置き換えます。

または素敵な Bash スクリプトとして (これを 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

次のように使用します。

gitrepo-info larowlan pisi reel

これにより、GitHub のpisi/reelリポジトリに関する情報が得られます。

于 2012-03-07T23:41:02.050 に答える
11

Github APICORS対応であるため、ブラウザから JavaScript を使用して:

fetch('https://api.github.com/repos/webdev23/source_control_sentry')
  .then(v => v.json()).then((v) => {
     console.log(v['size'] + 'KB')
  }
)

于 2020-11-05T09:10:50.987 に答える
2

You can do it using the Github API

This is the Python example:

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)
于 2020-11-11T16:00:37.430 に答える