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.
-
Install GitHub CLI if you don’t have it.
-
Authenticate:
gh auth login(Choose HTTPS or SSH; for private repos you need appropriate scopes.)
gh auth status -
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=1Or with GNU parallel for speed:
gh repo list ORG_NAME --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' | parallel -j 8 gh repo cloneUseful flags:
--no-archived— skip archived repos--source— only non-forks- Add
--visibility private/publicif 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):
- Go to GitHub → click your profile picture → Your organizations.
- Click the organization.
- Click Settings.
- Scroll to the Danger zone.
- Click Delete this organization.
- 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:
- Authenticate & clone/backup everything.
- Verify the local copies.
- 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 cloneaccepts extragit cloneflags after--.--depth=1creates a shallow clone (only the latest commit of the default branch).-I {}tellsxargsto 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.
One-liner (recommended)
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:
- Creates a folder for each organization (
ELT73A-2025-1-A,ELT73A-2025-1-B, …). - Clones every repository inside that org with
--depth=1. - Deletes all
.gitfolders so only the source code remains. - 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.