Anirudh Sharma
BlogDSASkillsPortfolio
© Anirudh SharmaBlogDSASkillsGitHubEmail

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.

Anirudh Sharma6 min read · Aug 2026 · DevOps & Automation

The problem. Create a private GitHub repository for each of 60+ project folders on an external drive, and push them all, without clicking through the GitHub website 60 times or filling up the drive.

The fix. Keep each project's Git data in a temp folder on the fast internal disk (GIT_DIR) and point it at the source folder (GIT_WORK_TREE). Let the GitHub CLI handle login, keep junk and secrets out with an exclude list, and check which repos already exist before creating any. An AI agent now runs all of it from one skill file.

Time saved. About 4 hours: a whole afternoon of clicking became 3 minutes.

Get the agent skill that does all of this →

In this post

  1. The Problem: 60 Folders, 60 Repositories
  2. What Broke, and Why
  3. The Fix: Keep Git's Data Off the Drive
  4. Skills, Not Scripts
  5. Common Mistakes
  6. Other Ways to Do It
  7. What Each Piece Does
  8. Questions People Ask
  9. What to Automate Next

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:

  1. A clean Git history on the main branch.
  2. A private repository under my GitHub organization.
  3. No junk: no node_modules/, no dist/, no macOS metadata, no .env files.
  4. 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:

text
fatal: cannot copy '.../templates/hooks/...': No space left on device

macOS 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.
bash
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 .git folders.
  • 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/exclude skips node_modules/, ._* files and .env, even in projects with no .gitignore.
  • Login just works. gh auth setup-git lets 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 list shows which repositories exist already, so they are not created twice.
How fast? All 60 projects took under 3 minutes, with nothing written to the external drive.

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.

Read the skill

Common Mistakes

  1. Not cleaning up folder names. Monthly House Cleaning is not a valid repository name. Replace spaces and symbols with -: Monthly-House-Cleaning.

  2. Trusting each project's .gitignore. Old projects often don't have one. Put your own exclude list in $GIT_DIR/info/exclude before staging anything.

  3. 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-git once and push to the plain https://github.com/... URL.

  4. Assuming every repository is new. If 5 of the 60 already exist, gh repo create fails on them. Check with gh repo list first.

  5. Force-pushing by habit. --force on 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:

bash
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 to Automate Next

Once the repositories exist, these are good next jobs to hand to an agent:

  • Branch protection for every repository. Require pull request reviews and passing checks, and block direct pushes to main, across all the new repositories. gh api --method PUT /repos/OWNER/REPO/branches/main/protection with a JSON ruleset, once per repository.
  • The same CI workflow in every repository. Give every project linting, tests and a build check. A companion skill that commits a standard .github/workflows/ci.yml to each repository.
  • Old zip archives with several versions. Projects that only exist as a pile of dated zip files. Unzip each version in order into a temp folder and commit it with GIT_COMMITTER_DATE set to the archive's date, so the history matches reality.
What I tried first, and why it failed

What I tried

  • Running git init and gh repo create by hand in each folder.
  • A quick shell loop with git add . and git 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 .git folders (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).

  • GitHub CLI
  • Git
  • Agent Skills
  • AI Agents
  • Automation
← All posts