How to Change a Public GitHub Repository to Private

GitHub repositories can be set as public (visible to everyone) or private (visible only to you and collaborators). If you’ve started with a public repository and later decide to restrict access—due to sensitive code, project maturity, or collaboration policies—you can easily change it to private.

This guide walks you through the steps to convert a public GitHub repository into a private one, with considerations and best practices.


🔐 What Happens When You Make a Repo Private?

  • The repository becomes invisible to the public.
  • Only collaborators and organization members with access can view or contribute.
  • Existing forks of the repository will remain public unless deleted or made private by their owners.
  • GitHub Pages (if enabled) will be disabled automatically.

✅ Step-by-Step: Make a Public GitHub Repo Private

🔹 Step 1: Log in to GitHub

Go to https://github.com and sign in to your account.


🔹 Step 2: Open Your Repository

Navigate to the public repository you want to make private.


🔹 Step 3: Go to Repository Settings

  1. Click the “Settings” tab (on the right side of the repository menu).
  2. Scroll down to the “Danger Zone” section.

🔹 Step 4: Change Visibility

  1. In the Danger Zone, find the section titled “Change repository visibility”.
  2. Click the “Make private” button.
  3. Read the warning and confirm by typing the repository name if prompted.
  4. Click “I understand, make this repository private.”

🔹 Step 5: Done

Your repository is now private. GitHub will automatically update visibility and access settings.


🔄 Reverting Back to Public

You can make the repository public again at any time by following the same steps and clicking “Make public.”


⚠️ Important Notes

  • Only the repository owner or organization admins can change visibility settings.
  • GitHub Free users can make private repositories, but there are limitations on features (e.g., limited collaborators).
  • Organization repositories may have additional visibility rules and admin restrictions.

🧠 Best Practices

  • Audit collaborators: Ensure only trusted individuals have access after making the repo private.
  • Review secrets: Even if you make a repo private, any previously exposed API keys or secrets should be rotated.
  • Update documentation: Inform your team if the repo’s visibility change impacts build tools or deployment scripts.

✅ Summary

TaskAction
Navigate to repositoryGo to your repo on GitHub
Access settingsClick Settings > Scroll to Danger Zone
Make privateClick “Make private”, confirm action
Revert to public (optional)Click “Make public”

🚀 Final Thoughts

Changing your repository from public to private is quick, but the implications—access control, visibility, and project exposure—are important. Always review collaborators, clean up exposed data, and communicate changes with your team or contributors.

Sharing Is Caring:

Leave a Comment