Whether you’re working on a personal project, a proprietary application, or anything that shouldn’t be publicly accessible, making a GitHub repository private is a simple and effective way to control who can see your code.
In this guide, you’ll learn how to make a GitHub repository private—both when creating a new one and after it already exists.
🔐 What Is a Private Repository?
A private repository is only visible to you and the collaborators you explicitly invite. It won’t show up in search results or your public GitHub profile unless you grant access.
✅ Option 1: Create a Private Repository (New)
- Go to GitHub and log in.
- Click the + icon at the top-right → New repository.
- Fill in repository details (name, description, etc.).
- Under “Visibility”, select:
🔘 Private
- Click Create repository.
That’s it—your repo is private from the start.
✅ Option 2: Make an Existing Repository Private
If your repository is already public and you want to make it private:
- Go to the repository page on GitHub.
- Click on the Settings tab (right side of the top menu).
- Scroll down to the Danger Zone section.
- Look for “Change repository visibility”.
- Click Change visibility → Select Make private.
- Confirm the action in the dialog box.
⚠️ You must be the repository owner or have admin rights to do this.
🚫 Things to Keep in Mind
- Free GitHub users can create private repos (as of GitHub’s 2019 update).
- Private repos are not accessible by the public unless shared explicitly.
- You can still collaborate—just invite others via Settings > Collaborators.
- Actions, webhooks, and GitHub Pages may behave differently on private repos.
🔄 Can You Revert It?
Yes! You can change a private repo back to public any time by following the same steps and choosing “Make public”.
Just be careful—once public, any previously private code may be indexed or cached by search engines.
Summary
Task | Steps |
---|---|
Make new repo private | Select “Private” during creation |
Make existing repo private | Go to Settings → Danger Zone → Change visibility |
Revert to public | Follow same steps and choose “Make public” |
Using private repositories allows you to keep your work confidential until you’re ready to share it—or never share it at all.