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
- Click the “Settings” tab (on the right side of the repository menu).
- Scroll down to the “Danger Zone” section.
🔹 Step 4: Change Visibility
- In the Danger Zone, find the section titled “Change repository visibility”.
- Click the “Make private” button.
- Read the warning and confirm by typing the repository name if prompted.
- 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
Task | Action |
---|---|
Navigate to repository | Go to your repo on GitHub |
Access settings | Click Settings > Scroll to Danger Zone |
Make private | Click “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.