Git
How to Make a Repository Private on GitHub?
GitHub is a widely used platform for hosting repositories, enabling developers to collaborate on projects efficiently. By default, when you create a repository, you can choose to make it public or private. However, you might need to change an existing repository to private to restrict access and maintain confidentiality.
In this blog, we’ll walk you through how to make a repository private on GitHub, ensuring only invited collaborators can view and contribute to the repository.
What Is a Private Repository?
A private repository is accessible only to the repository owner and the collaborators who have been explicitly invited. Unlike public repositories, private repositories do not appear in searches and are hidden from non-authorized users.
Private repositories are ideal for:
- Proprietary projects
- Confidential code or sensitive files
- Testing environments
How to Make an Existing Repository Private on GitHub
Follow these simple steps to make a repository private:
Step 1: Log in to GitHub
Go to GitHub.com and log in to your account using your credentials.
Step 2: Navigate to Your Repository
- Click on your profile picture in the top-right corner.
- Select “Your repositories” from the dropdown menu.
- Choose the repository you want to make private.
Step 3: Go to Repository Settings
- Inside the repository, locate the navigation bar at the top.
- Click on the “Settings” tab (it’s usually on the far right).
Step 4: Change Visibility to Private
- Scroll down to the “Danger Zone” section at the bottom of the Settings page.
- Find the option that says “Change repository visibility”.
- Click on the “Change visibility” button.
Step 5: Confirm Your Action
- A dialog box will appear to confirm the action.
- Read the warning carefully. Changing a repository to private will restrict access to it.
- Type the repository name to confirm.
- Click on “I understand, change repository visibility” to finalize the process.
What Happens After Making a Repository Private?
- Access Restrictions: Only you and invited collaborators will have access to the repository.
- Fork Restrictions: Public forks of the repository will remain public unless you explicitly delete or manage them.
- Visibility: The repository will no longer appear in searches or your public GitHub profile.
How to Invite Collaborators to a Private Repository
If you want to allow others to access your private repository:
- Go to your repository and click on the “Settings” tab.
- Select “Collaborators and teams” from the left menu.
- Click on “Add people” and enter the GitHub username or email of the person you want to invite.
- Set their permission level (Read, Write, Maintain, Admin) and send the invitation.
Frequently Asked Questions (FAQs)
1. Can I make a public repository private for free?
Yes, GitHub allows users with free accounts to create private repositories.
2. Will making a repository private affect my collaborators?
No, collaborators who already have access to the repository will retain their permissions.
3. Can I switch back to public later?
Yes, you can change a private repository back to public at any time by following the same steps above.
Final Thoughts
Making a repository private on GitHub is quick and straightforward. Whether you’re working on sensitive projects or simply want to limit access, private repositories provide the control and confidentiality you need.
Follow the steps in this guide to secure your code and collaborate safely with trusted team members.