What changing repository visibility does
GitHub lets you switch any repository you own between public (anyone on the internet can see it) and private (only people you invite can see it). This is a one-click change in your repository settings, and it takes effect immediately. The code itself stays exactly the same — you are only changing who can view it.
Public repositories are visible in search results and on your GitHub profile. Private repositories are hidden from search and from your public profile, though the URL still works if someone has the direct link. Changing visibility does not affect branches, pull requests, or any code you have already pushed.
Key Takeaways
- Repository visibility settings are in the Settings tab of your repository, under the Danger Zone section near the bottom.
- Changing from public to private hides the repository from search results and your public profile immediately.
- You must own the repository or have admin access to change its visibility — collaborators cannot make this change.
- GitHub's free tier allows unlimited private repositories, so there is no cost to making a repository private.
- If your repository is part of an organization, organization owners may have policies that restrict visibility changes.
How to make a repository private
Log into GitHub and open the repository you want to change. Click the Settings tab near the top right of the repository page, just after Code, Issues, and Pull Requests.
Scroll down to the bottom of the Settings page. You will see a section labeled Danger Zone with a red background. Inside that section, find the option that says Change repository visibility. Click the button next to it that says Change visibility.
A dialog box will appear asking you to confirm. It will show the current visibility (Public) and ask you to type the repository name to confirm the change. Type the exact name of your repository as shown, then click I understand, change repository visibility. The repository is now private.
How to make a repository public
The process is identical in reverse. Open Settings, scroll to the Danger Zone, and click Change visibility. This time the dialog will show Private as the current setting. Type the repository name to confirm, and click the button to make it public.
When you make a repository public, anyone on the internet can find it through GitHub search, see it on your profile, and clone or fork it. If the repository contains sensitive information like API keys or passwords, do not make it public — delete those secrets first or move them to environment variables.
What happens to collaborators and access when you change visibility
People who already have access to the repository keep their access when you change visibility. If someone was a collaborator on a public repository, they remain a collaborator when you make it private. If you make a private repository public, existing collaborators still have the same level of access they had before.
Making a repository private does not remove anyone from it. If you want to revoke someone's access, you must remove them from the Collaborators list in Settings, under the Access section. This is separate from changing visibility.
When you cannot change visibility
You must be the repository owner or have admin access to change visibility. If you are a collaborator with write or read access, the Change Visibility button will not appear in Settings. Ask the repository owner to make the change, or ask them to grant you admin access first.
If your repository is part of an organization, the organization owner or an organization admin may have set policies that prevent members from changing visibility. If the button is missing or disabled, check with your organization admin about their visibility policies.
Common mistakes and how to avoid them
The most common mistake is typing the repository name incorrectly in the confirmation dialog. GitHub requires you to type it exactly as it appears — including capitalization and hyphens. If you type it wrong, the button will stay disabled and you cannot proceed. Copy and paste the name from the dialog itself if you are unsure.
Another mistake is making a repository public without checking for secrets first. If your code contains API keys, database passwords, or authentication tokens, remove them before making the repository public. Even if you delete them later, they remain in the git history and can be found by anyone who clones the repository. Use a tool like git-filter-repo to remove secrets from history if you have already pushed them.
Do not assume that making a repository private deletes it or hides it from people who already have the URL. Private repositories are still accessible by direct link to anyone who has the link and has been granted access. If you want to truly hide a repository, you must delete it entirely.
Frequently Asked Questions
Can I change visibility if I forked someone else's repository?
Yes. When you fork a repository, you become the owner of your fork. You can make your fork private or public regardless of the original repository's visibility. The original repository owner cannot control your fork's visibility.
What happens to issues and pull requests when I change visibility?
They stay exactly as they are. Issues and pull requests on a public repository remain visible when you make it private, but only to people who now have access to the private repository. If the repository was public and someone commented on an issue, that comment history is preserved but hidden from public view.
Can I schedule a visibility change for later, or does it happen right away?
The change happens immediately when you confirm it. GitHub does not offer scheduled visibility changes. If you need to make a change at a specific time, you must do it manually at that time.
If I make a repository private, can people still see my commits in their network graph?
No. Once a repository is private, only people with access to that repository can see its commit history and network graph. Public activity related to that repository disappears from public view.
Does changing visibility affect GitHub Pages if I have a site hosted from this repository?
If your repository powers a GitHub Pages site and you make the repository private, the site will no longer be publicly accessible. GitHub Pages requires the source repository to be public (or the site to be on a paid GitHub Enterprise plan). Check your Pages settings after changing visibility to see if your site is still live.