Skip to content

Latest commit

 

History

History
72 lines (47 loc) · 2.63 KB

File metadata and controls

72 lines (47 loc) · 2.63 KB

GitHub Commands - Overview

Costa Rica

GitHub Cloud2BR OSS - Learning Hub

Last updated: 2026-01-20


List of References (Click to expand)

Check Repo Sizes in an Organization

  1. Create a GitHub Personal Access Token (PAT):
  • Go to GitHub → Settings → Developer settings → Personal access tokens.

  • Create a Fine‑grained token with at least read‑only repo scope.

  • If your org enforces SSO, click Authorize for your org after creating the token.

  • Copy the token (it looks like ghp_xxxxx...).

    image
  1. Store the Token in PowerShell:

    $env:GITHUB_TOKEN="ghp_yourtokenhere"
  2. Call the GitHub API: Run PowerShell script that lists all repos in your org with their sizes. Please change {YOUR-ORG-NAME}

    In GB

    $headers = @{ Authorization = "token $env:GITHUB_TOKEN" }
    $response = Invoke-WebRequest -Uri "https://api.github.com/orgs/{YOUR-ORG-NAME}/repos?per_page=100" -Headers $headers
    $repos = $response.Content | ConvertFrom-Json
    
    # Show name and size in GB
    $repos | Select-Object name, @{Name="SizeGB";Expression={[math]::Round($_.size/(1024*1024),2)}} | Sort-Object SizeGB -Descending

    E.g in GB:

    image

    In KB:

    $headers = @{ Authorization = "token $env:GITHUB_TOKEN" }
    $response = Invoke-WebRequest -Uri "https://api.github.com/orgs/{YOUR-ORG-NAME}/repos?per_page=100" -Headers $headers
    $repos = $response.Content | ConvertFrom-Json
    
    # Show name and size in MB
    $repos | Select-Object name, @{Name="SizeMB";Expression={[math]::Round($_.size/1024,2)}} | Sort-Object SizeMB -Descending

    E.g in KB:

    image
Total views

Refresh Date: 2026-04-06