Skip to content
Kloudle Logo
Academy academy

How to Make a GitHub Repository Private (2026)

By Akash Mahajan · · 5 min read · intermediate

To make a GitHub repository private, open the repository, select Settings, scroll to Danger Zone, choose Change visibility, select Private, and complete GitHub’s confirmation prompts. You need repository administrator access, and an organization owner may restrict who can make the change.

GitHub repository visibility guides: Make a repository private · Make a repository public · Change visibility with the gh CLI

Before you continue: changing visibility has consequences that are not reversed by simply changing it back. Review the checklist below before confirming.

Make a public GitHub repository private

  1. Sign in to GitHub and open the repository.
  2. Select Settings below the repository name. If the tab is hidden, open the repository navigation dropdown first.
  3. On the General settings page, scroll to Danger Zone.
  4. Next to Change repository visibility, select Change visibility.
  5. Select Change to private.
  6. Confirm that you are changing the correct repository.
  7. Select I have read and understand these effects.
  8. Select Make this repository private and complete any authentication prompt.

GitHub may vary the wording of the confirmation controls, but the path remains Repository → Settings → General → Danger Zone → Change visibility.

What changes when a GitHub repository becomes private?

GitHub currently documents these important effects for a public-to-private change:

  • Public forks are detached into a separate network; they do not become private copies of the parent repository.
  • GitHub erases the repository’s stars and watchers, which can affect repository ranking.
  • Code scanning becomes unavailable unless the organization has the required GitHub Code Security access and seats.
  • Some GitHub Free features are unavailable on private repositories.
  • GitHub Advanced Security entitlements and Dependabot behavior depend on the owner’s plan and licenses.

Changing visibility is not a way to remove information that has already been copied. Existing clones, published packages, releases, cached pages, leaked secrets, and detached public forks need their own response.

What should you check before making the repository private?

Use this short pre-change checklist:

  1. Review the public fork network and decide how you will communicate with fork owners.
  2. Export or record star and watcher counts if they matter to the project.
  3. Check whether GitHub Pages, Actions, rulesets, code scanning, Dependabot, packages, or external integrations depend on public access.
  4. Rotate any credential that was committed to the repository. Making the repository private does not make an exposed secret safe again.
  5. Tell collaborators how their access will change.
  6. Check links, package documentation, webhooks, deployment keys, and automation that read the repository anonymously.

Why can’t I change the repository visibility?

The most common reasons are:

  • You do not have administrator access to the repository.
  • An organization owner has restricted visibility changes to organization owners.
  • An enterprise policy prevents the requested visibility.
  • The repository is a fork whose visibility is controlled by its repository network.
  • A managed-user or enterprise configuration limits the available visibility choices.

For an organization repository, ask an organization owner to check Organization settings → Member privileges → Repository visibility change and any enterprise policy above the organization.

Can I make an internal repository private?

Internal visibility is available to eligible enterprise accounts. An internal repository is visible to all enterprise members, so it should not be treated as private. The same Change visibility control can move an eligible repository between internal and private, subject to organization and enterprise policy.

Change repository visibility with GitHub CLI

For a repeatable or scripted change, use gh repo edit. GitHub CLI requires an explicit flag acknowledging the consequences:

gh repo edit OWNER/REPOSITORY \
  --visibility private \
  --accept-visibility-change-consequences

Verify the result instead of assuming the command succeeded:

gh repo view OWNER/REPOSITORY --json nameWithOwner,visibility

Official GitHub references

Updated August 2026.

Akash Mahajan Founder & CEO

Akash Mahajan

Founder & CEO

Akash is the founder of Kloudle, a developer-first cloud security scanner. He’s spent 20+ years in cybersecurity and now builds tools that make securing cloud infra simple, fast, and frustration-free.