Batch management tools for GitHub fork repositories — sync or delete forks in one go.
| Script | Description |
|---|---|
sync-forks.sh |
Batch sync all fork repositories in a GitHub organization with their upstream parents |
delete-forks.sh |
Batch delete all forked repositories under a GitHub user account |
clone-forks.sh |
Discover upstream repos via ariacompute forks, then fork them into craftsland |
Ubuntu/Debian:
sudo apt install ghmacOS:
brew install ghOr download from GitHub CLI official website
gh auth loginexport GITHUB_TOKEN="your_github_pat_token"Recommended to add the token to environment variables or config files to avoid setting it manually each time.
Batch sync all fork repositories for GitHub user craftsland with their upstream parents.
# Basic usage — sync all forks
./sync-forks.sh
# Dry Run mode — preview without making changes
./sync-forks.sh --dry-run
# Force sync — execute even if already up to date
./sync-forks.sh --force
# Show help
./sync-forks.sh --help| Parameter | Description |
|---|---|
--dry-run |
Preview mode, shows what would be synced without making changes |
--force |
Force sync, execute even if fork is already in sync with upstream |
--help |
Show help information |
- Fetch all fork repositories for user
craftslandvia GitHub API - For each fork, resolve its upstream (parent) repository
- Use
gh repo syncto pull updates from upstream into the fork - Log success / failure per fork and print a summary
=========================================
GitHub Fork Batch Sync for craftsland
=========================================
Syncing fork: craftsland/project-a
From parent: original-org/project-a
✓ Successfully synced craftsland/project-a
Syncing fork: craftsland/project-b
From parent: original-org/project-b
✓ Successfully synced craftsland/project-b
=========================================
Sync Summary
=========================================
Total forks processed: 2
Successful: 2
Failed: 0
Discover upstream repositories from all forks in the ariacompute GitHub organization, then fork the same upstream repos into the craftsland user account.
# Basic usage — fork all discovered upstream repos
./clone-forks.sh
# Dry Run mode — preview without making changes
./clone-forks.sh --dry-run
# Force mode — fork even if craftsland already has a fork
./clone-forks.sh --force
# Show help
./clone-forks.sh --help| Parameter | Description |
|---|---|
--dry-run |
Preview mode, shows which upstream repos would be forked without making changes |
--force |
Force fork even if craftsland already has a fork of the same upstream |
--help |
Show help information |
- Fetch all fork repositories in the
ariacomputeorganization via GitHub API - For each fork, resolve its upstream (parent) repository
- Deduplicate — if the same upstream was forked multiple times, fork it only once
- Skip upstreams that
craftslandhas already forked (unless--force) - Use
gh repo forkto fork each upstream into thecraftslandaccount - Log success / failure per upstream and print a summary
=========================================
GitHub Fork Cloner
=========================================
Source org (to discover upstreams): ariacompute
Target user (to fork into): craftsland
Fetching fork list from organization: ariacompute...
Found upstream: upstream-org/project-a (via fork ariacompute/project-a)
Found upstream: upstream-org/project-b (via fork ariacompute/project-b)
Skipping already-forked: upstream-org/project-c (craftsland already has a fork)
Found 2 upstream repo(s) to fork:
- upstream-org/project-a
- upstream-org/project-b
Forking upstream: upstream-org/project-a
Into account: craftsland
✓ Successfully forked upstream-org/project-a
Forking upstream: upstream-org/project-b
Into account: craftsland
✓ Successfully forked upstream-org/project-b
=========================================
Fork Summary
=========================================
Total upstream repos processed: 2
Successful: 2
Failed: 0
Batch delete all forked repositories under GitHub user craftsland.
# Interactive mode — list forks, confirm, then delete one by one
./delete-forks.sh
# Dry Run mode — preview without deleting
./delete-forks.sh --dry-run
# Force mode — skip confirmation and delete all forks directly
./delete-forks.sh --force
# Show help
./delete-forks.sh --help| Parameter | Description |
|---|---|
--dry-run |
Preview mode, shows which forks would be deleted without deleting them |
--force |
Skip confirmation prompt and delete all forks immediately |
--help |
Show help information |
- Fetch all repositories under user
craftsland, filtering to only forks - Display the full list and ask for confirmation (unless
--force) - Delete each fork via
DELETE /repos/{full_name}API - Print per-repo status and a final summary
=========================================
GitHub Fork Batch Delete for craftsland
=========================================
Fetching fork list...
Found 5 fork(s):
- craftsland/forked-repo-1
- craftsland/forked-repo-2
- craftsland/forked-repo-3
- craftsland/forked-repo-4
- craftsland/forked-repo-5
Are you sure you want to delete ALL 5 fork(s)? [y/N] y
Deleting fork: craftsland/forked-repo-1
✓ Successfully deleted craftsland/forked-repo-1
...
=========================================
Delete Summary
=========================================
Total forks processed: 5
Deleted: 5
Failed: 0
- sync-forks: Token needs
reposcope to sync. - clone-forks: Token needs
reposcope to fork repos. The authenticatedghuser must have permission to fork the upstream repos. - delete-forks: Token needs
delete_reposcope. Deletion is irreversible — always run--dry-runfirst to verify. - All scripts use
gh api/gh repounder the hood and are compatible withGITHUB_TOKEN.
1. Token not set
Error: GITHUB_TOKEN environment variable is not set
Solution: Export GITHUB_TOKEN in your shell.
2. Not authenticated with GitHub CLI
Error: HTTP 401: Unauthorized
Solution: Run gh auth login to re-authenticate.
3. Insufficient permissions
Error: Resource not accessible by integration
Solution: Verify the token has the required scopes (repo for sync, delete_repo for delete).
MIT License