📝 Git & GitHub

Public vs Private Repositories on GitHub ⚖️

0
Author
04e5cc8b-58ac-4bdc-bdee-661bbb
📅
Published
06.05.2026
⏱️
Reading time
3 min
👁️
Views
73
🌱
Level
Beginner

Choosing between Public and Private? Let’s break down the differences and when to use each!

Repository Types

Public Repositories 🌍

Who can see it: The entire internet

Advantages

Free — unlimited number
Portfolio — employers can view your code
Open Source — others can use and improve it
Collaboration — anyone can suggest changes (Pull Requests)
GitHub Pages — free website hosting
Visibility — indexed by Google

Disadvantages

No privacy — everyone sees the code
Can’t store secrets — API keys will be compromised
Code accessible to competitors

Private Repositories 🔒

Who can see it: Only you + invited collaborators

Advantages

Confidentiality — only authorized users
Business code — can store commercial projects
Secrets safer (but still use env variables!)
Access control — you choose who can see it

Disadvantages

Not visible in portfolio
Harder collaboration — need to invite everyone
No GitHub Pages on the Free plan
Not indexed by Google

Comparison

Feature Public Private
Price (Free plan) ✅ Unlimited ✅ Unlimited
Visible to the internet ✅ Yes ❌ No
Collaborators ∞ (anonymous) Up to 3 (Free)
GitHub Actions ✅ 2000 min/month ✅ 2000 min/month
GitHub Pages ✅ Yes ❌ No (Free)
Portfolio ✅ Yes ❌ No
Issues/PRs public ✅ Yes ❌ No

When to Use Public?

✅ Learning projects

python-course-homework/
my-first-website/
javascript-exercises/

Why: Employers will see your progress!

✅ Open source libraries

awesome-python-library/
react-cool-component/
useful-cli-tool/

Why: Other developers can use and improve them!

✅ Portfolio projects

my-blog/
portfolio-website/
pet-project-api/

Why: Show your skills to employers!

✅ Documentation and guides

programming-cheatsheets/
devops-notes/
security-best-practices/

Why: Help the community + build your reputation!

When to Use Private?

✅ Commercial projects

company-internal-tool/
client-website/
startup-mvp/

Why: Code is intellectual property!

✅ Projects with secrets

.env files
database credentials
API keys

Why: Even in private it’s better not to store them, but safer than public!

✅ Unfinished work

experiment-new-idea/
draft-article/
work-in-progress/

Why: Don’t expose “raw” code publicly!

✅ Personal notes

daily-notes/
password-manager-export/
finance-tracker/

Why: Private information!

How to Change Visibility?

Make Public → Private

  1. Open the repository on GitHub
  2. Settings
  3. Danger ZoneChange visibility
  4. Make private
  5. Confirm by typing the repository name

Make Private → Public

Same steps, but Make public.

⚠️ Warning: After publishing, all code becomes visible to everyone!

Check before publishing

Make sure to check:

# Search for potential secrets
grep -r "password" .
grep -r "api_key" .
grep -r "secret" .
grep -r "token" .

If found — remove them and rewrite history (git filter-branch)!

Best Practices

For public repositories

✅ Add a good README.md
✅ Choose a license (MIT, Apache, GPL)
✅ Create .gitignore
✅ Add CODE_OF_CONDUCT.md
✅ Set up CONTRIBUTING.md for collaborators
✅ Use GitHub Actions for CI/CD

For private repositories

✅ Restrict access to only necessary people
✅ Use .env files for secrets (in .gitignore!)
✅ Regularly review who has access
✅ Enable branch protection for main
✅ Require code review before merge

Fun Facts and Common Mistakes

Fun Facts

📊 GitHub Statistics:

  • 100+ million public repositories
  • 80% of repositories are public
  • 28 million developers
  • 1.9 billion contributions per year

🎓 GitHub Education:

Students get free GitHub Pro:
- Unlimited private repos (already on Free!)
- GitHub Actions 3000 minutes/month
- 2GB GitHub Packages storage

Sign up: https://education.github.com/pack

Common Mistakes

❌ Mistake 1: Secrets in a public repository

# ❌ BAD
API_KEY = "sk_live_123456789"
DATABASE_URL = "postgres://user:pass@localhost/db"

Fix:

# ✅ GOOD
import os
API_KEY = os.getenv("API_KEY")
DATABASE_URL = os.getenv("DATABASE_URL")

❌ Mistake 2: Making everything private

Portfolio projects should be visible to employers!

❌ Mistake 3: Forgetting .gitignore

Check that you’re not committing:
- node_modules/
- .env
- venv/
- .idea/, .vscode/

Conclusion

Use Public for:
- Learning
- Portfolio
- Open Source

Use Private for:
- Commercial work
- Secrets
- Unfinished work

Golden rule: When in doubt — start private, then go public! 🔒→🌍

Your reaction to the article

💬 Comments (0)

🔐 Sign in to leave a comment
🚪 Login
💭

No comments yet

Be the first to share your opinion about this article!

🔗 Similar

Similar articles

Continue learning with these materials

📝

Git Hosting Platforms: Full Comparison 🏆

GitHub, GitLab, Bitbucket — which one to choose? A complete comparison with up-to-date data.

📅 06.05.2026 👁️ 52
📝

What Is a Git Commit and Why Do You Need It? 📸

A commit is a saved snapshot of your project at a specific point in time...

📅 06.05.2026 👁️ 55
📝

Why Git won over every other version control syst…

Today Git is the de facto standard for version control in software development. But it...

📅 06.05.2026 👁️ 50

Did you like the article?

Subscribe to our updates and receive new articles first. Grow with PyLand!