GitHub Account and Repository

Create a free GitHub account and your first online repository.

GitHub hosts Git repositories in the cloud so you can back up, share, and collaborate. Sign up for free at github.com.

Create a repository

  1. Click the + in the top-right and choose New repository.
  2. Give it a name and choose Public or Private.
  3. Optionally add a README, a .gitignore, and a license.
  4. Click Create repository.

GitHub then shows the commands to connect an existing local repo or clone the new one.

Example

Example · bash
# GitHub shows these after creating an empty repo:
git remote add origin https://github.com/you/my-project.git
git branch -M main
git push -u origin main

When to use it

  • A developer creates a public GitHub repo to share an open-source library so others can star, fork, and contribute.
  • A startup creates a private repo to host their product codebase, granting access only to team members.
  • A student creates a repo to showcase portfolio projects, linking it on their resume for recruiters to browse.

More examples

Create a repo with GitHub CLI

Uses the official GitHub CLI to create a remote repository without opening a browser.

Example · bash
# Install and authenticate GitHub CLI first
gh auth login

# Create a new public repo
gh repo create my-portfolio --public --description "My dev portfolio"

Push existing local repo to GitHub

Connects a local repo to the new GitHub remote and pushes the initial commit history upstream.

Example · bash
# After creating the repo on GitHub
git remote add origin https://github.com/username/my-portfolio.git
git branch -M main
git push -u origin main

Clone your new repo fresh

Clones the GitHub repo to a new local directory and confirms the commit history arrived correctly.

Example · bash
gh repo clone username/my-portfolio
cd my-portfolio
git log --oneline

Discussion

  • Be the first to comment on this lesson.