Git
How to Make Your GitHub Account Private?
GitHub is a powerful platform for sharing code and collaborating on projects, but there are times when you may want to keep parts of your work private. This guide will walk you through how to make your repositories private, control who has access to your content, and protect your personal information on GitHub.
Why Consider Privacy on GitHub?
There are several reasons why making parts of your GitHub account private is beneficial:
- Security: Sensitive projects, proprietary code, or personal information should be shielded from the public eye.
- Professionalism: Keeping unfinished or experimental projects private can present a polished profile to recruiters and collaborators.
- Collaboration Control: Private repositories allow you to control who can view or contribute to a project, ensuring that only trusted individuals have access.
GitHub allows you to set specific privacy levels for both repositories and certain parts of your profile. Below, we’ll cover the steps for managing these privacy settings.
Step 1: Making a Repository Private
One of the simplest ways to protect your code and data on GitHub is by making individual repositories private. This means only you and collaborators you specifically invite can see and access the repository’s contents.
1.1 Creating a Private Repository
When creating a new repository, you can set it as private during the setup:
- Go to GitHub.com and log into your account.
- Click on the + icon in the top-right corner, then select New repository.
- In the repository setup page, give your repository a name, then select Private under “Repository visibility.”
- Click Create repository.
Now, this repository is only accessible by you and those you specifically invite as collaborators.
1.2 Making an Existing Repository Private
If you want to make an already public repository private, follow these steps:
- Go to the repository you wish to make private.
- Click on Settings in the menu bar near the top of the page.
- Scroll down to the Danger Zone section at the bottom.
- Click Change repository visibility.
- Select Make private and confirm the action.
Note: If you’re using a free GitHub account, keep in mind that making a public repository private will lose stars and watchers.
Step 2: Managing Your Profile Privacy Settings
GitHub also allows you to make certain aspects of your personal profile private. This includes hiding your contributions, limiting the visibility of your activity, and keeping personal details like your email address hidden.
2.1 Hiding Contribution Activity on Your Profile
If you prefer that others don’t see your activity timeline, such as commits or issues you’ve opened, you can hide your contribution activity:
- Go to your profile by clicking on your avatar in the top-right corner and selecting Your profile.
- Click on Edit profile.
- In the Contribution settings section, uncheck Show private contributions on my profile.
This setting helps you keep your activity timeline private while still allowing you to work openly on specific repositories or projects.
2.2 Hiding Your Email Address
By default, GitHub makes your email address public in commit history. You can avoid this by configuring GitHub to use a noreply email address or by adjusting your email visibility settings:
- Go to Settings by clicking on your avatar in the top-right corner and selecting Settings.
- In the left-hand sidebar, click Emails.
- Check the box Keep my email address private.
- Optionally, select Block command line pushes that expose my email to prevent accidental exposure.
GitHub will now use a noreply email address in commits, keeping your personal email secure.
2.3 Limiting Who Can See Your Organizations
If you’re part of multiple GitHub organizations and don’t want them visible on your profile, you can hide them from public view:
- Go to your profile, and select Organizations from the left sidebar.
- Click on the organization you want to make private.
- Click Private to change the visibility for that organization.
Step 3: Inviting Collaborators to Private Repositories
If you’re working on a private repository and want to invite others to collaborate, GitHub allows you to add them without making the repository public.
- Go to the repository where you want to add collaborators.
- Click on Settings, then go to the Manage access tab.
- Click on Invite a collaborator, and enter their username or email.
- The invitee will receive a request to access your private repository. Once they accept, they’ll have access according to the permission level you assign (e.g., read, write, or admin).
Step 4: Enabling Two-Factor Authentication for Additional Security
Keeping your GitHub account private isn’t just about hiding content; it’s also essential to secure your account. Two-factor authentication (2FA) is a simple but effective way to add an extra layer of protection.
- Go to Settings by clicking on your avatar in the top-right corner and selecting Settings.
- In the Account security section, click Enable two-factor authentication.
- Follow the prompts to set up 2FA with either a mobile authenticator app or SMS.
Enabling 2FA ensures that even if someone obtains your password, they’ll need the second verification step to access your account.
Additional Tips for Privacy on GitHub
- Use .gitignore for Sensitive Files: Avoid committing sensitive files like configuration files, API keys, and passwords. Use a
.gitignore
file to prevent these files from being tracked by Git. - Monitor Repository Permissions: Regularly review and update collaborator permissions to ensure only trusted individuals have access.
- Be Careful with Forks: Forked repositories inherit the visibility of the original. Ensure that private information doesn’t unintentionally become public.
- Regularly Audit Your Public Repositories: Over time, review the repositories you have made public to confirm you’re comfortable with the information they contain.
Conclusion
Maintaining privacy on GitHub is crucial for protecting sensitive information and controlling the visibility of your work. By setting your repositories as private, adjusting your profile privacy settings, and inviting collaborators securely, you can ensure your GitHub account reflects your preferences for privacy. With these steps, you’re able to continue leveraging GitHub’s collaboration features while keeping your projects secure.