Before you make a private repo public: 6 checks
Scan history for secrets, review logs and issues, check workflows, and re-enable protections after.
Published here , updated · 3 sources · Resume reading
Changing visibility exposes the entire repository: every branch, every commit, every issue, every Actions log [1][2]. Run these six checks before you flip the switch from private to public, and treat a history that ever held credentials as a reason to publish a fresh tree instead of hoping a rewrite is perfect [3].
One minute: scan history first
Checking the current branch is not enough. A key deleted years ago is still in history [1].
gitleaks git . --verboseYou should see either "no leaks found" or a list of findings with file paths and commit hashes. If gitleaks is not installed yet, install it from the project docs, or run TruffleHog against the same clone [3].
If you find a secret, rotate it with the provider first, then decide whether to rewrite history or start fresh [1][3]. Deleting the line from main alone leaves every old commit readable after the repo goes public.
Six checks sit between private and public; secret history routes you to a fresh repo after rotation.
2. Check Actions logs and artifacts
Workflow logs and uploaded artifacts become public with the repository. Search them for tokens, internal URLs, and error messages that reveal infrastructure [2]. Download a recent failed run and open the raw log before you assume CI is clean. Uploaded actions/upload-artifact bundles are easy to forget because they are not in Git.
3. Review issues, PRs, and the wiki
Comments, attachments, and revision history all become visible. Look for screenshots with credentials, customer data, or internal network details [2]. Wiki pages and gist-like attachments linked from issues travel with the public story even when main looks tidy.
4. Audit workflow files for unsafe patterns
Check that workflows do not expose secrets to untrusted PRs. Avoid checking out and running code from pull_request_target without validation [2]. Public forks can open PRs that exercise your workflows differently than private collaborators did. Re-read any workflow that prints env dumps, uploads whole workspaces, or uses wide permissions: write-all.
5. Confirm licensing and third-party code
Public visibility does not grant reuse rights. Add an open-source license if you want others to use the code. Check that dependencies, fonts, and images may legally be redistributed [2]. A private company font or a vendor SDK with a no-redistribution clause is a legal problem the moment the tree is public, even if every secret scan is clean.
6. Re-enable branch protections after the change
GitHub disables push rulesets when a private repository becomes public [2]. After changing visibility, go to Settings, then Rules (or Branches), and re-enable the protections you need: required reviews, required status checks, and any rulesets that blocked force-pushes. Use GitHub branch protection settings for the four toggles on main.
Also re-check Actions secrets and variables. Values remain, but who can trigger workflows that consume them may change with fork PR policies. Pair this with the hung-job and minute-saving habits in one line caps a hung GitHub Actions job and save GitHub Actions minutes so the new public CI does not burn six-hour hangs on the first spam PR.
The safest path for repos with secret history
If the repository ever contained credentials, a fresh public repo is more reliable than history rewriting. Copy the current tree, commit, push to a new public repo, and archive the old one privately [3]. GitHub documents history scrubbing paths, but a missed ref, mirror, or fork keeps the old blob alive [1]. Rotation still comes first either way.
For day-to-day prevention before a public flip, scan on every push: scan secrets before pushing AI code. For client bundles that accidentally ship secrets, see public env prefixes. Shell history is another leak path covered in scrub secrets from shell history.
What "public" actually publishes
Branches you forgot, annotated tags, Git LFS objects, GitHub Packages linked to the repo, GitHub Discussions if enabled, and project boards depending on settings. Walk Settings once with a second person who did not build the repo. Fresh eyes catch the staging URL in an old issue attachment.
Mistakes that turn into incident tickets
Flipping visibility on Friday afternoon without a secret scan of full history [1].
Deleting a .env from main and calling the repo clean.
Leaving pull_request_target workflows that checkout untrusted code [2].
Forgetting to restore branch protections after GitHub clears push rulesets [2].
Publishing without a license, then arguing in issues about reuse [2].
Rewriting history while old forks and CI caches still hold the blob [1][3].
After the switch
Watch the first public PRs, Dependabot alerts, and Actions runs. Confirm required checks still block merges. If a scanner finds a late secret, rotate immediately and treat the public window as a breach window even if the key looked unused.
How to scan when gitleaks is new to the laptop
Install gitleaks from its upstream releases, then run it at the repository root so it walks commits, not only the working tree [3]. TruffleHog's verified-secret mode is a useful second opinion because it can tell you whether a finding still authenticates [3]. Keep the scanner output private; it may contain the secret you are trying to retire.
If the org already runs secret scanning on GitHub, do not treat that as a substitute for a local full-history pass before the visibility change. Push protection helps future pushes. It does not un-publish blobs that become public with the repo [1].
Issues and PR archaeology that scanners miss
Search issue text for password, vpn, 10., sk-, and internal hostnames. Open image attachments. Check whether a deleted comment still appears in email notifications or linked Slack archives you cannot scrub. Wikis have their own history. Discussions, if enabled, are another surface [2].
Release assets and GitHub Packages tied to the repository can expose binaries built with embedded config. Browse Releases and Packages before the flip. An old dist.zip with a staging .env is a classic miss.
Workflow review prompts
Open every file under .github/workflows and ask:
- Does this workflow run untrusted PR code with secrets in scope?
- Do logs print environment dumps or
env:blocks that expand secrets into step output? - Do artifacts upload the whole workspace, including
.envor credential files? - Are
pull_request_targetcheckouts pinned and validated [2]?
Public repositories attract drive-by PRs. Private habits that trusted every collaborator do not survive that shift. Cap hung jobs while you are there (one line that caps a hung GitHub Actions job) so a malicious or accidental infinite loop cannot sit on a runner for six hours.
License and third-party inventory
Add a LICENSE that matches what you intend. Inventory fonts, icons, vendor SDKs, and data files. If a dependency's license forbids redistribution of its binaries, public source that vendors those binaries is still a problem [2]. When in doubt, remove the vendor tree from the public copy and document how to fetch it privately.
Rulesets and branch protection after the flip
GitHub's documented behavior is that push rulesets get disabled when a private repository becomes public [2]. Re-enable required reviews, required status checks, signed commits if you use them, and block force-pushes on default branches. Confirm admin bypass rules still match who should actually bypass. Then open a test PR from a fork (if forks are allowed) and prove the required checks still gate merges.
Fresh repo procedure (when history is dirty)
- Rotate every secret the scanner found, plus anything adjacent in the same vault.
- Create a new empty public repository.
- Copy the current working tree (no
.git) into a freshgit init, or use an orphan branch approach you understand end to end. - Push only the clean history you intend to publish.
- Archive the old private repository and lock down who can read it.
- Update remotes, CI, package names, and documentation links [1][3].
This is more work than a visibility toggle. It is cheaper than an incident response thread that starts with "we thought we deleted that key in 2023."
Browse the Dev tools topic.
Send this to the friend who is about to flip their private repo to public without a scrub.

Keep this guide
Questions about this guide
Is deleting a secret from HEAD enough?
No. Git history keeps every version. Anyone can check out an old commit and read the deleted file. Rotate the secret.
What happens to branch protections?
GitHub disables push rulesets when a private repo becomes public. Re-check and re-enable them after the change.
When is a fresh public repo safer than rewriting history?
When credentials ever lived in the private history. Copy the current tree to a new public repo and archive the old one privately.
Do Actions logs become public too?
Yes. Workflow logs and uploaded artifacts become visible with the repository, so search them before flipping visibility.
Sources
- GitHub docs: removing sensitive data from a repositorydocs.github.com
- TruffleSecurity blog: securely open-sourcing on GitHubtrufflesecurity.com