Pular para o conteúdo principal

Organizações

Como criar uma organização no GitHub


Download (clone) all repos from a GitHub organization, then delete the organization.​

1. Clone / download all repositories​

Best method: GitHub CLI (gh) — simplest and official.

  1. Install GitHub CLI if you don’t have it.

  2. Authenticate:

    gh auth login

    (Choose HTTPS or SSH; for private repos you need appropriate scopes.)

    gh auth status
  3. Clone everything:

    # List and clone all repos (adjust limit if you have >1000)
    gh repo list ORG_NAME --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' | xargs -L1 gh repo clone
    # List and clone all repos (adjust limit if you have >1000)
    gh repo list ORG_NAME --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' | xargs -L1 -I {} gh repo clone {} -- --depth=1

    Or with GNU parallel for speed:

    gh repo list ORG_NAME --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' | parallel -j 8 gh repo clone

    Useful flags:

    • --no-archived — skip archived repos
    • --source — only non-forks
    • Add --visibility private / public if needed

Alternative (API + curl + git):

# Needs a Personal Access Token with repo + read:org scopes
export GITHUB_TOKEN=your_token_here
ORG=ORG_NAME

curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/orgs/$ORG/repos?per_page=100&type=all" | \
jq -r '.[].clone_url' | while read url; do
git clone "$url"
done

(Handle pagination if you have >100 repos.)

Notes:

  • This clones the default branch (or full history depending on how you clone). For a true mirror of all branches/tags use git clone --mirror.
  • Issues, PRs, wikis, releases, etc. are not included in a plain git clone. For full backups you need extra tools (e.g. GitHub migration exports on Enterprise, or third-party backup scripts).
  • Private repos require authentication and the correct permissions.

2. Delete the organization​

This is irreversible. All repositories, issues, PRs, wikis, projects, packages, etc. are permanently deleted. The organization name is locked for 90 days.

Requirements: You must be an organization owner.

Steps (official):

  1. Go to GitHub → click your profile picture → Your organizations.
  2. Click the organization.
  3. Click Settings.
  4. Scroll to the Danger zone.
  5. Click Delete this organization.
  6. Read the warnings, type the exact organization name, and confirm.

Before deleting:

  • Make sure you have local copies of everything important (repos + any other data you need).
  • Consider transferring repos you want to keep to another account/org first.
  • Optionally archive the organization instead of deleting (makes it read-only).

Official docs: Deleting an organization account.


Recommended order:

  1. Authenticate & clone/backup everything.
  2. Verify the local copies.
  3. Only then delete the organization.

If you need a full backup that includes issues/PRs/etc., say so and I can point you to more specialized tools.

Use this command:

gh repo list ORG_NAME --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' | xargs -L1 -I {} gh repo clone {} -- --depth=1

Explanation​

  • gh repo clone accepts extra git clone flags after --.
  • --depth=1 creates a shallow clone (only the latest commit of the default branch).
  • -I {} tells xargs to replace {} with each repository name so the flags are passed correctly.

Optional improvements​

Faster (parallel):

gh repo list ORG_NAME --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' | parallel -j 8 gh repo clone {} -- --depth=1

Skip archived repos:

gh repo list ORG_NAME --limit 1000 --no-archived --json nameWithOwner --jq '.[].nameWithOwner' | xargs -L1 -I {} gh repo clone {} -- --depth=1

Clone into a specific folder:

mkdir -p my-org-backup && cd my-org-backup
gh repo list ELT73A-2024-2 --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' | xargs -L1 -I {} gh repo clone {} -- --depth=1

Replace ORG_NAME with your actual organization name.

After cloning with --depth=1, you can remove all .git folders so you only keep the source code.

Run this from the directory that contains all the cloned repos:

find . -type d -name ".git" -exec rm -rf {} +

Safer version (shows what will be deleted first)​

# Preview
find . -type d -name ".git"

# Then delete
find . -type d -name ".git" -exec rm -rf {} +

Alternative with xargs​

find . -type d -name ".git" | xargs rm -rf

Full workflow (clone + remove .git)​

# Create a base directory
mkdir -p ELT73A-LAB-TPL-backup
cd ELT73A-LAB-TPL-backup

# 1. Clone shallow
gh repo list ELT73A-LAB-TPL --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' | \
xargs -L1 -I {} gh repo clone {} -- --depth=1

# 2. Remove all .git folders
find . -type d -name ".git" -exec rm -rf {} +

After this, each repository folder will contain only the code (no Git history, no ability to git pull or push).

Here’s the adapted version for organizations ELT73A-2025-1-A through ELT73A-2025-1-X:​

  1. Creates a folder for each organization (ELT73A-2025-1-A, ELT73A-2025-1-B, …).
  2. Clones every repository inside that org with --depth=1.
  3. Deletes all .git folders so only the source code remains.
  4. Moves to the next organization.

Skip orgs that don’t exist / have no access (avoids errors):

# Create a base directory
mkdir -p ELT73A-S22-2026-1-backup
cd ELT73A-S22-2026-1-backup

# Loop from A to X
for letter in {A..X}; do
org="ELT73A-S22-2026-1-$letter"

# Skip if the org doesn’t exist or you have no access
if ! gh api "orgs/$org" &>/dev/null; then
echo "Skipping $org (not found or no access)"
continue
fi

echo "=== Processing $org ==="
mkdir -p "$org"
cd "$org"

gh repo list "$org" --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' | \
xargs -L1 -I {} gh repo clone {} -- --depth=1

find . -type d -name ".git" -exec rm -rf {} +
cd ..
done

Faster cloning with parallel (if you have GNU parallel installed):

gh repo list "$org" --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' | \
parallel -j 8 gh repo clone {} -- --depth=1

Just paste the script into your terminal and run it.

Uma org por grupo vs. times em uma única org​

Para o seu caso (labs lab00…lab10, templates, PlatformIO/STM32, automação com gh), quase sempre a melhor opção é uma única organização com times (Grupo-A, Grupo-B, …).


Comparação rápida​

Critério1 org por grupo (ELT73A-S22-2026-2-A, …)1 org + times (ELT73A-S22-2026-2 + grupo-a)
Isolamento entre gruposMuito forteBom (repos privados + permissão só do time)
AdministraçãoPesada (N orgs)Simples (1 org)
Criar labs em massaScript por org ou loop em N orgsUm loop só, mais simples
TemplatesOrg de templates à parte ou copiar N vezesUm lab00-template na mesma org
Times / membrosCada org tem seus membrosTimes nativos + membership fácil
Visão do professorTrocar de org o tempo todoTudo num só lugar
Limites do GitHubRisco de bater limite de orgs / convitesBem mais confortável
Billing / settingsRepetir política N vezesConfigurar uma vez
Autograding / CIDispersoCentralizado
“Aluno não vê o outro”NaturalCom repo privado + só o time no repo, também ok
Complexidade para o alunoURLs longas, várias orgsUm padrão: lab00-grupo-a

Uma org por grupo​

Vantagens

  • Isolamento máximo (um grupo não “existe” na org do outro).
  • Cada grupo pode ter settings próprios (se um dia precisar).
  • Modelo parecido com “cada time = uma conta/org”.

Desvantagens

  • Muitas orgs para criar, convidar alunos e manter.
  • Scripts e docs ficam mais longos (ELT73A-S22-2026-2-A/LAB05, …).
  • Template costuma ficar em outra org (ELT73A-LAB-TPL) e o fluxo --template / permissões complica.
  • Professor perde visão única (issues, Actions, busca de repos).
  • No plano educacional/free, gerenciar dezenas de orgs vira atrito real.

Faz sentido quando: grupos são projetos longos, quase independentes, com admins diferentes, ou há requisito formal de isolamento total.


Uma org + times (Grupo-A, Grupo-B, …)​

Vantagens

  • Um só lugar para templates, labs e projeto.
  • Times do GitHub são feitos para isso: membros + permissão em repos.
  • Automação simples (lab00-grupo-a … lab00-grupo-x).
  • Aluno clona um padrão fixo; professor lista tudo com um gh repo list.
  • Fácil conceder push só ao time certo.
  • README, CI e componentes Docusaurus ficam estáveis.

Desvantagens

  • Todos os grupos “moram” na mesma org (nomes de repo precisam ser claros).
  • Se alguém errar permissão e deixar um repo interno/público demais, o isolamento cai — exige disciplina no script (private + team push só no repo do grupo).
  • Alunos da org podem, em alguns casos, ver que a org existe e listar o que a política da org permitir (repos privados de outro time continuam inacessíveis sem permissão).

Faz sentido quando: turma de disciplina, vários labs, mesmo professor, automação e templates — o seu cenário.


Isolamento de verdade (o que importa na prática)​

O que impede o Grupo B de ver o código do Grupo A não é “org separada” por si só; é:

  1. Repositório private
  2. Time só do grupo com acesso (push / pull)
  3. Alunos não serem owners da org
  4. Scripts que nunca adicionam o time errado

Com isso, 1 org + times isola tão bem quanto N orgs para uso acadêmico normal.


Recomendação para ELT73A / S22​

EscolhaRecomendação
Padrão da disciplina1 organização ELT73A-S22-2026-2 + times Grupo-A … Grupo-X
Reposlab00-template, lab00-grupo-a, …, projeto-grupo-a
AlunosMembros do time; não owners
TemplatesNa mesma org, marcados como template
Docs (Docusaurus)Componente com abas por grupo, como o LabTeamMembers

Use 1 org por grupo só se houver regra institucional de isolamento extremo ou cada grupo for um “mini-projeto” com gestão própria o semestre inteiro.


Resumo em uma frase​

Para laboratórios de uma turma: uma org com times é melhor — menos trabalho, melhor automação, templates simples e isolamento suficiente com repos privados. Uma org por grupo só compensa se o isolamento administrativo total valer o custo operacional.