Public and Private Repositories
Asha's recipe-box is public, so anyone can read it. Her cousin wants to start a repository for a family cookbook that includes grandma's secret recipes and relatives' phone numbers. The choice between public and private decides who can see a repository and everything in its history.
The rule
Public means anyone can see all of it, including history; private means only people you invite.
Public repositories:
- Anyone on the internet can view the files, the full commit history, issues and pull requests.
- Anyone can clone or fork it. Only people you give access can push.
- They suit open-source projects, portfolios, learning projects and documentation.
Private repositories:
- Only you, people you add as collaborators, and members of an organisation who have been given access can see them.
- They suit unfinished work, personal notes, coursework you should not share, and anything containing information that must not be public.
- Free accounts can have private repositories and invite collaborators to them.
You can change visibility later in the repository's Settings, under the section for dangerous actions. Think before you do it:
- Private → public exposes the entire history. A password that was committed and then "deleted" three months ago becomes readable by everyone, because it is still in an old commit.
- Public → private hides the repository from now on, but it cannot recall copies. Anyone who already cloned or forked it keeps their copy.
One more point that surprises people: public is not the same as open source. Without a licence file, others may view and fork your code on GitHub, but they have no clear legal permission to reuse it elsewhere. If you want people to reuse your work, add a licence.
The shortcut
Ask "Would I be comfortable if every line in every commit were on a billboard?" Yes → public is fine. No → private, and keep secrets out of the repository anyway.
recipe-box
Recipes Asha is happy to share, and nothing personal in the history. Billboard test: yes. Public, with a licence so others may reuse the recipes.
The trap is treating "private" as a place for secrets such as passwords and API keys. Private limits who can read the repository, but anyone you add, and any tool you connect, can see it too. Secrets belong in ignored files or a secret manager, never in commits.
Drills
Answer fast — trust the rule.
Who can see a public repository's commit history?
Who can push to a public repository by default?
A private repository has an API key in a commit from last year, since removed. What happens if it is made public?
Asha's public repository has no licence file. Which statement is true?
Remember
- Public means anyone can see all of it, including history; private means only people you invite.
- Billboard test before choosing, and review history before going public.
- Public is not open source without a licence, and private is no place for secrets.
