7 Habits Before You Make a Repo Public
How I scrub, scan and check a repo before it goes public, with gitleaks and three AI reviewers

I just published my AI agent setup as a public GitHub repo. Its scripts and config came from a live setup. That setup is full of host names, folder paths and private settings. One slip and they're on the internet. Deleting a file later doesn't remove it from older commits.
These seven habits grew out of that repo. Most of them are what it went through. A few came out of the reviews afterward, and I'll use them next time. They work for any repo, with or without AI agents doing the work.
Habit 1: Publish copies, never your live files
Don't make your working folder public. Make a new folder and copy in only the files you'll publish. Leave the old .git folder behind, because it holds the whole old history. Scrub the copy and leave the live folder alone.
- Host names become a placeholder, like
myhost. In scripts, use$(hostname -s)so each machine fills in its own. - Personal paths go back to sensible defaults, like
$HOME/vault. - Names, dates, quotes and anything else about you come out.
- Your time zone becomes UTC.
- Keys, tokens, passwords and
.envfiles stay in the live folder. - Software you don't own stays out. The README says where to get it.
- Add a LICENSE if you want people to reuse your code. I used MIT.
Then run git init in the new folder. Before the first commit, add a .gitignore for .env files, keys, logs, work folders and state files. Run git status and check nothing private is listed. .gitignore keeps files out of git. It can't remove a file that's already committed.
Set the name and email for this repo too. GitHub shows them on every commit. Its email settings give you a private noreply address. Turn on "Block command line pushes that expose my email" while you're there.
git config user.name "Your Public Name"
git config user.email "[email protected]"
Every commit also stores your time zone offset. Commit in UTC so it shows +0000:
export TZ=UTC
git add .
git commit -m "First commit"
Habit 2: Scan with gitleaks before the first push
gitleaks looks for API keys, tokens, passwords and private keys. Run it on your own machine before you push anything to GitHub.
Run it in Docker. Mount the repo read-only and cut the scanner off from the network. Save this as compose.yaml in a folder outside the repo, so your real path never ends up in it:
services:
gitleaks:
image: zricethezav/gitleaks:v8.30.1
network_mode: none
volumes:
- /path/to/repo:/repo:ro
Then run it twice from that folder:
docker compose run --rm gitleaks git /repo
docker compose run --rm gitleaks dir /repo
git scans every commit on every branch. dir scans the files as they are now, including anything not committed yet. A clean run ends with "no leaks found".
If it finds something, the output shows the secret. Keep that output out of commits, tickets and chats. A clean scan lowers the risk. It doesn't prove there's nothing there, which is why Habit 3 exists.
Habit 3: Search the history for your own patterns
gitleaks knows what a key looks like. It doesn't know your host names, user name, folder paths or IP ranges. It doesn't know your email or your real name either. You have to search for those yourself.
Put your own values in P. The ones below are examples. Escape the dots with a backslash.
P='myhost|youruser|192\.168\.|me@example\.com|Real Name'
git rev-list --all | while read -r c; do git --no-pager grep -inE "$P" "$c"; done
git log --all --format='%an %ae %cn %ce %s %b' | grep -inE "$P"
git log --all --name-only --format= | sort -u | grep -iE "$P"
git for-each-ref --format='%(refname) %(contents)' | grep -inE "$P"
grep -rInE --exclude-dir=.git "$P" .
After setting P, the commands check five places:
- File contents in every commit.
- Author names, emails and commit messages.
- File names in every commit.
- Tag messages.
- The folder as it is now.
These skip binary files. Check images, PDFs and archives yourself, including photo metadata.
A file you cleaned in commit 3 is still sitting in commit 1. If an old commit has a hit, start the repo over. On a new repo, that's easier than rewriting history.
Habit 4: Have other models review it
I gave the whole repo to three AI reviewers: Grok, Codex and Antigravity. Each ran in its own Docker container with the same brief: find anything private, anything broken, and anything that doesn't match the README or my post about the setup.
They came back with about 45 findings between them. Some were repeats, some were wrong, and some were real bugs I'd have shipped. A script that could resume the wrong session. A restore that picked the older snapshot. Containers that kept a changed config after a restart.
- Only do this after Habits 2 and 3 are clean. Docker limits what a reviewer can see on your machine. It doesn't stop the files you send from leaving. Treat anything you send as given to that company.
- Give each reviewer every file you plan to publish, not a summary. Never
.git, ignored files or keys. - Check every finding yourself before you change anything.
- If a reviewer finds something private, add it to
Pand start the repo over. Then run Habits 2 and 3 again.
Habit 5: Push to a private repo first
Create the repo as private on GitHub and push the clean history to it.
Then check that it really is private, from outside. Your login can see your private repos. A check while logged in proves nothing. Run this with no GitHub token:
curl -s -o /dev/null -w '%{http_code}\n' https://api.github.com/repos/YOU/REPO
- 404 means the public can't see it. A typo also gives 404. Check the name against
git remote -v, without the.giton the end. - 200 means anyone can read it.
- 403 or 429 means you hit GitHub's rate limit. Wait and try again.
If a secret ever reaches GitHub, revoke it first. Then delete the repo and push the clean copy to a new one. A force-push isn't enough, because GitHub can keep old commits.
Habit 6: Build and run it from a fresh clone
A repo that only works on your machine isn't ready. Clone the private repo into a new folder. Don't copy your working folder, because untracked files can hide what's missing. Follow only the README, the way a stranger would.
- If it uses Docker, build every image from the clone with
--no-cache --pull. Ship a.dockerignorethat keeps.git,.envand keys out of the images. - Run everything and check it does what the README says.
- Test scripts with a throwaway HOME. They still run as you, so use a container or a spare user for anything risky. If they use tmux, give the test its own server:
tmux -L test. - Clean up after: test images, volumes, folders and the test tmux server.
If you had to do anything the README doesn't say, fix the README. If you changed any file, commit it, run Habits 2 and 3 again, and push.
Habit 7: Go public, then prove it from outside
Before you flip it, check what else goes public with it. Your local branch list can be out of date, so ask GitHub:
git ls-remote --heads --tags origin
Then check issues, releases, wiki pages and Actions logs on GitHub. Delete anything you don't want seen. Pull requests can't be deleted. If one has something private in it, start a fresh repo instead.
Now flip the repo to public. Then turn on Secret Scanning and Push Protection in its settings. On a personal account they only appear once the repo is public. They guard future pushes. They don't undo what's already there.
Check it the way the world sees it:
- Logged out, the repo page, the API and the raw files all return 200.
- The public branches and tags point at the same commits as yours. Run both commands with no saved login and compare. The lists should match line for line:
GIT_TERMINAL_PROMPT=0 git -c credential.helper= ls-remote --heads --tags --refs https://github.com/YOU/REPO.git | sort
git for-each-ref --format='%(objectname)%09%(refname)' refs/heads refs/tags | sort
- Every link in the README opens. Any link to the repo from your own site opens too.
If a secret shows up after it's public, assume it's already been copied. Revoke it first. Forks and clones keep it even after you delete your repo. Then delete the repo and publish a clean one.
Checklist
- New folder, no old
.git, secrets left behind git init,.gitignorebefore the first commit,git statuschecked- Public name, noreply email, commits in UTC, LICENSE if wanted
- gitleaks
gitanddirboth clean, before the first push - Own patterns searched in contents, commit details, file names, tags and the folder
- Outside reviews done after the scans, every finding checked
- Pushed private, logged-out check returns 404 on the right name
- Built and run from a fresh clone, README alone, scans rerun after any fix
- GitHub branches, tags, issues and releases checked before the flip
- Public, logged-out checks return 200, refs match, links work, secret scanning on
The repo is github.com/Zenshinzo/ai-agent-setup. The setup itself is in 7 Habits of My AI Agent Setup.