Git & GitHub · Your First Repository

Creating a Repository

A repository (repo) is one project: its files plus their complete history. You can create one on GitHub in a minute.

Beginner 5 min Lesson 4 of 19Shows Git 2.47 and GitHub.com as of 2026. GitHub changes its layout from time to time; button names stay the same.
Before you start:Creating a GitHub Account
0/19 in Git & GitHub
On this page · 5 min · Beginner

Learning objectives#

  • Create a repository on github.com
  • Choose between public and private
  • Decide when to add a README, .gitignore and licence
  • Find your way around the repository page

Explanation#

Click + (top right) → New repository. Give it a short, lowercase name with hyphens, such as hello-github. The description is optional but helps people (and search) understand it.

Public repositories can be seen by anyone — ideal for learning projects and your portfolio. Private ones are visible only to you and the people you invite. You can switch later in Settings.

For a brand-new project, tick Add a README file so the repository is not empty and you can clone it straight away. Add a .gitignore template for your language (Node, VisualStudio, Python…) and a licence such as MIT if you want others to be able to reuse the code. If you are uploading a project that already exists on your computer, leave all three unticked.

The repository page shows the files, the README underneath, the branch selector, and tabs for Issues, Pull requests, Actions and Settings.

Step-by-step screens#

Drawings of github.com, the Git installer, VS Code and a terminal. GitHub changes its layout from time to time; the button names stay the same. The red numbers match the numbered actions under each picture; names on your computer will differ.

Loading pictures…

Code example: The same thing with the GitHub CLI#

ShellThe same thing with the GitHub CLI Illustrative
gh auth login                                   # once
gh repo create hello-github --public --add-readme --clone
cd hello-github
git log --oneline
Expected output
✓ Created repository asha/hello-github on GitHub
Cloning into 'hello-github'...
1a2b3c4 Initial commit

This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.

Step-by-step explanation#

  1. gh auth login connects the CLI to your account.
  2. gh repo create makes the repository with a README.
  3. --clone downloads it immediately.
  4. The first commit (“Initial commit”) contains the README.

Real-world use case#

For each new college assignment a student creates a private repository with a Node .gitignore, so node_modules never gets uploaded.

Common mistakes#

Ticking README for an existing local project

GitHub then has a commit your computer doesn’t, and the first push is rejected. Create it empty, or pull first.

Spaces and capitals in names

GitHub turns “My Project” into My-Project; short lowercase-with-hyphens names are easier to type and read.

Best practices#

  • One repository per project
  • lowercase-with-hyphens names
  • Always have a README
  • Pick the .gitignore template for your language

Remember this#

+ → New repository.

New project: tick README. Existing project: leave it empty.

Public = portfolio, private = just you.

Practice exercise#

Your task: Write the HTTPS clone URL for the repository hello-github owned by asha.

Show solution
Text Illustrative
https://github.com/asha/hello-github.git

Mini quiz#

Creating a Repository quizMultiple choice Question 1 of 1

You already have a project on your computer. What should you tick when creating the GitHub repository?

Score so far: 0/0

Want more? Practise all Git & GitHub MCQs · Git & GitHub interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.