Skip to the workspace
Pebellslearn by building
GitHub Essentials  ›  Lesson

Creating a Repository on GitHub

Creating Repositories 12 minTo publish an existing local repository, create an empty GitHub repository and push to it; to start fresh, create it with a README and clone it.

git github / Creating a Repository on GitHub

Explore each scene at your own pace.

01 · The rule

The rule

Creating a Repository on GitHub

Throughout the Remotes section, Asha's recipe-box already had a home at github.com/asha-dev/recipe-box. This lesson shows how that home was made, and the one checkbox choice that decides whether the first push goes smoothly.

The rule

Local project already? Create the GitHub repository empty, then push.

Click + in the top bar and choose New repository. The form asks for:

  • Owner: your account, or an organisation you belong to.
  • Repository name: short, lower-case, hyphenated, such as recipe-box.
  • Description: one line that appears on the repository page.
  • Visibility: public or private (the next lesson covers the choice).
  • Initialise options: add a README, add a .gitignore from a template, choose a licence.

The initialise options decide which route you are on.

Route 1, starting fresh on GitHub. Tick "Add a README" and choose a .gitignore template. GitHub creates a first commit. Then clone it to your machine and work from there.

Route 2, pushing an existing local repository, which was Asha's case. Leave all the initialise options off, so the GitHub repository is completely empty. GitHub then shows the commands to connect it:

git remote add origin https://github.com/asha-dev/recipe-box.git
git branch -M main
git push -u origin main

git branch -M main renames the current branch to main, which is harmless if it is already called that. After the push, refresh the page: the files, the README and every commit from your laptop are there.

Why keep it empty? If GitHub creates its own first commit and you also have local commits, the two histories share no starting point. Your push is rejected, and combining them needs extra steps that beginners should not have to face on day one.

A few habits help from the start: always include a README.md (in your local project, for Route 2), commit a .gitignore early, and choose a licence if you want others to reuse your work.

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