How I Pushed 60+ Projects to GitHub in Minutes, and Turned It Into an Agent Skill
Full drives, macOS ghost files and frozen logins broke every quick fix. One Git trick solved it, and now an AI agent does the whole job from a single Markdown file.
The Problem: 60 Folders, 60 Repositories
I had an external drive with over 60 old app folders: small tools, finance sheets, client dashboards, a few mobile apps.
Each one needed to become its own GitHub repository:
- A clean Git history on the
mainbranch. - A private repository under my GitHub organization.
- No junk: no
node_modules/, nodist/, no macOS metadata, no.envfiles. - One initial commit, pushed.
Doing that through the GitHub website means: click New repository, type the name, copy the URL, switch to the terminal, run four commands. Then do it 59 more times. That is three to four hours of clicking, and plenty of chances to push a secret by mistake.
So I tried to automate it. That is where things went wrong.
What Broke, and Why
A simple loop over the folders crashed on the fourth project. There were four separate problems.
The drive filled up
git init inside each folder writes hundreds of small files into .git/objects/. The drive was nearly full, and FAT32 and exFAT drives handle many small files badly. Git stopped with:
fatal: cannot copy '.../templates/hooks/...': No space left on devicemacOS ghost files got committed
On drives that are not APFS, macOS creates hidden ._ files next to real ones (like ._App.tsx). A plain git add . committed dozens of them.
The login prompt froze everything
git push stopped to ask for a password or a passphrase. In an unattended loop, it waited forever.
Big pushes timed out
Projects with images and videos overflowed Git's default HTTP buffer on the first push, and GitHub dropped the connection.
The Fix: Keep Git's Data Off the Drive
The breakthrough was separating Git's database from the project files.
Git lets you keep the .git data anywhere, using two environment variables:
GIT_DIR: where Git keeps its data. I pointed it at a temp folder on the fast internal disk, like/tmp/batch-git/my-app.git.GIT_WORK_TREE: where the project files are. That stays the folder on the external drive.
export GIT_DIR="/tmp/batch-git/my-app.git"
export GIT_WORK_TREE="/Volumes/ExternalDrive/Projects/my-app"With that in place:
- Nothing is written to the drive. Git only reads the project files. No space problems, no leftover
.gitfolders. - It is fast. All of Git's writing happens on the internal SSD.
- Junk and secrets stay out. An exclude list in
$GIT_DIR/info/excludeskipsnode_modules/,._*files and.env, even in projects with no.gitignore. - Login just works.
gh auth setup-gitlets Git use the GitHub CLI's login, so nothing prompts and no token ever goes into a URL or a file. - Re-running is safe.
gh repo listshows which repositories exist already, so they are not created twice.
Skills, Not Scripts
My first version of this was a long Python script. It worked on my laptop, with my paths, my drive and my GitHub organization. On anyone else's machine it needed editing before it did anything useful.
Now I write a skill instead: a short Markdown file that tells an AI agent (Claude Code, Cursor, Codex, Gemini CLI) what the job is, what to check and what never to do. The agent reads it and does the work on your machine, with your folders. It adapts to your OS, asks for what it is missing, and stops to show you the plan before it creates a single repository.
The skill for this post does everything above, plus the safety checks I learned the hard way:
- It asks for the folder, the owner and the visibility in one message.
- It shows a table of every folder, its repository name, and whether it is new, empty or already has commits.
- It never force-pushes over a repository that has commits unless you say so.
- It checks the staged files for secrets and files over 100 MB before every commit.
- It ends with a report: what was pushed, what was skipped and why.
Install it once, then just ask: "Push every project in /Volumes/Archive/Projects to my-org as private repos."
Agent skill
Batch-push project folders to GitHub
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.
Common Mistakes
-
Not cleaning up folder names.
Monthly House Cleaningis not a valid repository name. Replace spaces and symbols with-:Monthly-House-Cleaning. -
Trusting each project's
.gitignore. Old projects often don't have one. Put your own exclude list in$GIT_DIR/info/excludebefore staging anything. -
Putting tokens in URLs or files. A token in a remote URL shows up in your shell history and the process list. Run
gh auth setup-gitonce and push to the plainhttps://github.com/...URL. -
Assuming every repository is new. If 5 of the 60 already exist,
gh repo createfails on them. Check withgh repo listfirst. -
Force-pushing by habit.
--forceon a repository that already has commits throws them away. Only do it when you mean to.
Other Ways to Do It
Just one project, on a normal disk
The GitHub CLI can do it in one command once the first commit exists:
cd /path/to/my-app
git init -b main
git add .
git commit -m "Initial commit"
gh repo create your-org/my-app --private --source=. --remote=origin --push--source=. uses the current folder, sets up the remote and pushes in one step.
The GitHub MCP server
If your agent is connected to GitHub through MCP, it can open pull requests, comment on issues and edit single files. For pushing whole projects, the Git and gh commands above are faster and simpler.
What Each Piece Does
Every variable and flag in this post, and why it matters:
GIT_DIR- Tells Git where to keep its data instead of a .git folder in the project. Nothing is written to a full or slow external drive, so 'No space left on device' goes away.
GIT_WORK_TREE- Tells Git where the project files are when GIT_DIR is somewhere else. Git reads the files straight from the external drive, without needing a .git folder there.
gh auth setup-git- Makes Git use the GitHub CLI's login for github.com. Pushes never stop to ask for a password, and no token goes into a URL or a file.
--private- Creates the repository as private. Unfinished or client code is never public by accident.
-b main- Names the first branch main. Matches GitHub's default, so there is no master/main mix-up.
main:main- Pushes the local main branch to main on GitHub. Works without setting up a named remote first, which suits a temporary Git folder.
http.postBuffer- Raises Git's HTTP upload buffer to 500 MB. Stops HTTP 408 and 'RPC failed' errors on big first pushes.
Questions People Ask
Does this change anything in my project folders?
No. Git's data lives in the temp folder (GIT_DIR), and Git only reads the project files. The source drive can even be read-only.
What if a project has files over GitHub's 100 MB limit?
GitHub rejects the push. The skill checks for big files first and skips that project, so you can set up Git LFS for it (git lfs track "*.mp4") before pushing.
What if a repository already exists?
The skill checks gh repo list first. If the repository exists and is empty, it pushes. If it already has commits, it skips it and tells you, unless you say to overwrite it.
Does it work on Windows?
Yes. The steps are the same in PowerShell, with $env:GIT_DIR and $env:GIT_WORK_TREE and a temp folder under $env:TEMP. The agent adjusts the commands for you.
How does it log in to GitHub without me pasting a token?
gh auth login once, then gh auth setup-git. After that Git asks the GitHub CLI for credentials whenever it pushes, so the token never appears in a URL, a command or a file.
What I tried first, and why it failed
What I tried
- Running
git initandgh repo createby hand in each folder. - A quick shell loop with
git add .andgit push. - Uploading files one by one through the GitHub REST API.
What went wrong
- The external drive ran out of space while Git wrote its
.gitfolders (No space left on device). - macOS
._*metadata files ended up in the commits. - Git login prompts froze the loop.
- Large pushes timed out (
HTTP 408,RPC failed).
Why
- 60 separate Git databases did not fit on the drive.
- Folder names with spaces (
Billing Statement) broke the remote URLs. - Git's login prompt needs a person at the keyboard.
Setup: macOS or Linux (Windows works too), an external drive (FAT32, exFAT or APFS), Git, and the GitHub CLI (gh).