Turns a folder of 60+ old projects into one private GitHub repo each. Works from full or read-only drives, keeps secrets and junk out, and shows you the plan before it pushes anything.
Use it in two steps
Install. Claude Code: save the file as ~/.claude/skills/batch-push-folders-to-github/SKILL.md. Any other agent: paste the file into the chat.
Ask. For example:
Push every project in /Volumes/Archive/Projects to my-org as private repos.
When the agent picks it up: Turn a folder full of project folders into one GitHub repository each, created and pushed in one run. Use when the user wants to bulk-create repos, publish many local projects to GitHub, move a drive or archive of old apps into an organization, or push folders that sit on an external, read-only or nearly full drive.
Every immediate subfolder of one parent folder becomes its own GitHub repository, with one clean initial commit on main.
The trick that makes this safe and fast: the Git database never goes inside the project folder. Each project gets its Git data in a temp folder (GIT_DIR), pointed at the source with GIT_WORK_TREE. Nothing is written to the source drive, so it works on full, slow, read-only, FAT32 and exFAT drives, and leaves no .git folders behind.
Ask the user first
Ask for whatever is missing, in one message:
Source folder: the parent folder that holds the projects.
Owner: a GitHub username or organization.
Visibility: private (default) or public.
Commit author: only if git config --global user.email is empty.
Rules
Never write inside the source folders. Only read them.
Never put a token in a URL, a command or a file. Use gh auth setup-git so Git asks the GitHub CLI for credentials.
Never force-push to a repository that already has commits, unless the user says so for that repository.
Never commit secrets. Check what is staged before every commit (step 4).
Show the plan and wait for a yes before creating or pushing anything.
One failure does not stop the run. Record it, move on, report it at the end.
Steps
1. Check the tools
bash
git --versiongh --versiongh auth status
If gh is not logged in, ask the user to run gh auth login themselves (it is interactive), then continue. Then let Git use the CLI's login:
bash
gh auth setup-git
2. Survey the projects
For each immediate subfolder of the source folder (skip hidden ones like .Trash or .DS_Store):
Repo name: replace every character that is not a letter, digit, -, _ or . with -, collapse repeated -, and trim - from the ends. Monthly House Cleaning becomes Monthly-House-Cleaning. If two folders end up with the same name, stop and ask.
Size, and any file over 50 MB (GitHub warns) or 100 MB (GitHub rejects):
bash
du -sh "$SRC"find "$SRC" -type f -size +50M -not -path "*/node_modules/*"
Does it exist already? Fetch the owner's repositories once:
bash
gh repo list OWNER --limit 1000 --json name,isEmpty
GitHub repo names are case-insensitive, so compare in lowercase.
3. Show the plan, then wait
Print one table and ask the user to confirm:
#
Folder
Repository
Status
Size
Warnings
1
Monthly House Cleaning
my-org/Monthly-House-Cleaning
new
4 MB
2
budget-app
my-org/budget-app
exists, empty
12 MB
3
old-site
my-org/old-site
exists, has commits: skip
80 MB
1 file > 50 MB
4. Push each project
Run this for one project at a time, with SRC, REPO, OWNER and VISIBILITY filled in:
bash
export GIT_DIR="${TMPDIR:-/tmp}/batch-git/$REPO.git"export GIT_WORK_TREE="$SRC"rm -rf "$GIT_DIR" && mkdir -p "$GIT_DIR"git init -q -b main# Keep junk and secrets out, even if the project has no .gitignore.# (A .gitignore inside the project still applies too.)cat > "$GIT_DIR/info/exclude" <<'EOF'node_modules/dist/build/out/.next/coverage/__pycache__/*.pyc.venv/venv/.DS_Store._*Thumbs.db.env.env.*!.env.example*.pem*.key*.p12id_rsa*EOFgit add -Agit diff --cached --name-only # review this list (see below) before committinggit commit -q -m "Initial commit"gh repo create "$OWNER/$REPO" --$VISIBILITY # only for repos that don't exist yetgit push "https://github.com/$OWNER/$REPO.git" main:mainunset GIT_DIR GIT_WORK_TREE
Before the commit, look at the staged list:
Secrets: if anything looks like a credential (credentials.json, service-account*.json, *.keystore, .npmrc with a token, files containing PRIVATE KEY), unstage it with git rm --cached <file> and add it to the warnings.
Big files: if a file is over 100 MB, skip this project and tell the user it needs Git LFS.
Nothing staged: the folder is empty or fully ignored. Skip it.
If the commit fails because no author is set, run it as git -c user.name="NAME" -c user.email="EMAIL" commit ... with the details the user gave.
5. Report
End with one table: folder, repository link, and pushed, skipped (why) or failed (the error and the fix). Then delete the temp Git folders:
bash
rm -rf "${TMPDIR:-/tmp}/batch-git"
When something goes wrong
Error
Fix
No space left on device
GIT_DIR is on the full drive. Make sure it points to the temp folder.
HTTP 408, RPC failed, the remote end hung up
Run git config http.postBuffer 524288000 (it applies to this temp repo only) and push again.
Push asks for a username or password
Run gh auth setup-git again, then push.
Repository creation failed: name already exists
It exists with a different case. Use the existing name.
GH001: Large files detected
A file is over 100 MB. Skip the project, or set up Git LFS for it.
._App.tsx and other ._* files show up
macOS metadata from a non-APFS drive. The exclude list above removes them.
Windows
Same steps in PowerShell: set $env:GIT_DIR and $env:GIT_WORK_TREE, use $env:TEMP\batch-git as the temp folder, and remove the variables afterwards with Remove-Item Env:GIT_DIR, Env:GIT_WORK_TREE.
See the raw SKILL.md
batch-push-folders-to-github/SKILL.md
---name: batch-push-folders-to-githubdescription: Turn a folder full of project folders into one GitHub repository each, created and pushed in one run. Use when the user wants to bulk-create repos, publish many local projects to GitHub, move a drive or archive of old apps into an organization, or push folders that sit on an external, read-only or nearly full drive.---# Batch-push project folders to GitHubEvery immediate subfolder of one parent folder becomes its own GitHub repository, with one clean initial commit on `main`.The trick that makes this safe and fast: **the Git database never goes inside the project folder.** Each project gets its Git data in a temp folder (`GIT_DIR`), pointed at the source with `GIT_WORK_TREE`. Nothing is written to the source drive, so it works on full, slow, read-only, FAT32 and exFAT drives, and leaves no `.git` folders behind.## Ask the user firstAsk for whatever is missing, in one message:1. **Source folder**: the parent folder that holds the projects.2. **Owner**: a GitHub username or organization.3. **Visibility**: private (default) or public.4. **Commit author**: only if `git config --global user.email` is empty.## Rules- **Never write inside the source folders.** Only read them.- **Never put a token in a URL, a command or a file.** Use `gh auth setup-git` so Git asks the GitHub CLI for credentials.- **Never force-push** to a repository that already has commits, unless the user says so for that repository.- **Never commit secrets.** Check what is staged before every commit (step 4).- **Show the plan and wait for a yes** before creating or pushing anything.- **One failure does not stop the run.** Record it, move on, report it at the end.## Steps### 1. Check the tools```bashgit --versiongh --versiongh auth status```If `gh` is not logged in, ask the user to run `gh auth login` themselves (it is interactive), then continue. Then let Git use the CLI's login:```bashgh auth setup-git```### 2. Survey the projectsFor each immediate subfolder of the source folder (skip hidden ones like `.Trash` or `.DS_Store`):- **Repo name**: replace every character that is not a letter, digit, `-`, `_` or `.` with `-`, collapse repeated `-`, and trim `-` from the ends. `Monthly House Cleaning` becomes `Monthly-House-Cleaning`. If two folders end up with the same name, stop and ask.- **Size**, and any file over **50 MB** (GitHub warns) or **100 MB** (GitHub rejects): ```bash du -sh "$SRC" find "$SRC" -type f -size +50M -not -path "*/node_modules/*" ```- **Does it exist already?** Fetch the owner's repositories once: ```bash gh repo list OWNER --limit 1000 --json name,isEmpty ``` GitHub repo names are case-insensitive, so compare in lowercase.### 3. Show the plan, then waitPrint one table and ask the user to confirm:| # | Folder | Repository | Status | Size | Warnings ||---|--------|------------|--------|------|----------|| 1 | `Monthly House Cleaning` | `my-org/Monthly-House-Cleaning` | new | 4 MB | || 2 | `budget-app` | `my-org/budget-app` | exists, empty | 12 MB | || 3 | `old-site` | `my-org/old-site` | exists, has commits: **skip** | 80 MB | 1 file > 50 MB |### 4. Push each projectRun this for one project at a time, with `SRC`, `REPO`, `OWNER` and `VISIBILITY` filled in:```bashexport GIT_DIR="${TMPDIR:-/tmp}/batch-git/$REPO.git"export GIT_WORK_TREE="$SRC"rm -rf "$GIT_DIR" && mkdir -p "$GIT_DIR"git init -q -b main# Keep junk and secrets out, even if the project has no .gitignore.# (A .gitignore inside the project still applies too.)cat > "$GIT_DIR/info/exclude" <<'EOF'node_modules/dist/build/out/.next/coverage/__pycache__/*.pyc.venv/venv/.DS_Store._*Thumbs.db.env.env.*!.env.example*.pem*.key*.p12id_rsa*EOFgit add -Agit diff --cached --name-only # review this list (see below) before committinggit commit -q -m "Initial commit"gh repo create "$OWNER/$REPO" --$VISIBILITY # only for repos that don't exist yetgit push "https://github.com/$OWNER/$REPO.git" main:mainunset GIT_DIR GIT_WORK_TREE```Before the commit, look at the staged list:- **Secrets**: if anything looks like a credential (`credentials.json`, `service-account*.json`, `*.keystore`, `.npmrc` with a token, files containing `PRIVATE KEY`), unstage it with `git rm --cached <file>` and add it to the warnings.- **Big files**: if a file is over 100 MB, skip this project and tell the user it needs Git LFS.- **Nothing staged**: the folder is empty or fully ignored. Skip it.If the commit fails because no author is set, run it as `git -c user.name="NAME" -c user.email="EMAIL" commit ...` with the details the user gave.### 5. ReportEnd with one table: folder, repository link, and **pushed**, **skipped** (why) or **failed** (the error and the fix). Then delete the temp Git folders:```bashrm -rf "${TMPDIR:-/tmp}/batch-git"```## When something goes wrong| Error | Fix ||-------|-----|| `No space left on device` | `GIT_DIR` is on the full drive. Make sure it points to the temp folder. || `HTTP 408`, `RPC failed`, `the remote end hung up` | Run `git config http.postBuffer 524288000` (it applies to this temp repo only) and push again. || Push asks for a username or password | Run `gh auth setup-git` again, then push. || `Repository creation failed: name already exists` | It exists with a different case. Use the existing name. || `GH001: Large files detected` | A file is over 100 MB. Skip the project, or set up Git LFS for it. || `._App.tsx` and other `._*` files show up | macOS metadata from a non-APFS drive. The exclude list above removes them. |## WindowsSame steps in PowerShell: set `$env:GIT_DIR` and `$env:GIT_WORK_TREE`, use `$env:TEMP\batch-git` as the temp folder, and remove the variables afterwards with `Remove-Item Env:GIT_DIR, Env:GIT_WORK_TREE`.