Skip to the workspace
Pebellslearn by building
GitHub Essentials  ›  Capstone Project

Public and Private Repositories

Private vs Public 12 minA public repository and its whole history are visible to anyone, a private one only to invited people, and neither visibility replaces a licence or keeping secrets out of commits.

git github / Public and Private Repositories

Explore each scene at your own pace.

01 · The rule

The rule

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.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.