GitHub Introduction

What GitHub is, how it relates to Git, the words you'll see everywhere, and how to set up your account.

Lesson 1 of 30Beginner17 min read

GitHub is a website where developers keep their Git repositories online. Think of it as a shared home for code: you upload your project, and GitHub stores every commit, shows the files and their history in your browser, and lets other people see, copy or contribute to it, if you allow them.

Over 100 million developers use GitHub, including teams at Microsoft, Google and NASA, and it hosts famous open-source projects such as VS Code, React and Python itself. It's also where many beginners publish their first portfolio and first website.

In this lesson you'll learn how GitHub fits together with Git, the vocabulary you'll meet on every page, and how to set up your account and sign in from your computer.

Git and GitHub

  • Git is the program on your computer that records commits and branches. It works offline.
  • GitHub is an online service that stores a copy of your Git repository, called a remote, and adds collaboration tools.

Your everyday loop becomes: commit with Git on your computer, then push the commits to GitHub. Teammates pull them down to their own computers. Other services, such as GitLab and Bitbucket, work the same way; the Git commands are identical.

Words you'll see everywhere

TermMeaning
Repository (repo)A project and its full history
RemoteA copy of a repo stored somewhere else, such as GitHub
Push / pullSend your commits up / bring others' commits down
CloneDownload a full copy of a repo to your computer
ForkYour own copy of someone else's repo on GitHub
Pull request (PR)A proposal to merge one branch into another, with review
IssueA bug report, idea or task for a repo
StarA bookmark that also shows appreciation for a project

Setting up your account

  1. Go to github.com and choose Sign up. Use the same email you set with git config so your commits are linked to your profile.
  2. Pick a professional username; it becomes part of your profile address, github.com/username.
  3. Turn on two-factor authentication under Settings, Password and authentication. GitHub requires it for anyone who contributes code.
  4. Add a profile picture, a short bio and, if you like, a profile README: a repository with the same name as your username, whose README appears on your profile page.

Signing in from your computer

To push code, Git needs to prove who you are. GitHub doesn't accept your account password on the command line. The easiest options are:

  • GitHub CLI: install gh from cli.github.com and run gh auth login. It sets everything up for you.
  • Git Credential Manager, included with Git for Windows: the first time you push, a browser window asks you to sign in.
  • SSH keys, popular with experienced developers, which you add under Settings, SSH and GPG keys.

You only need to do this once per computer.

GitHub Syntax

Signing in with GitHub CLI

gh auth login
gh auth status

GitHub Summary

  • GitHub hosts Git repositories online and adds tools for working together.
  • Git runs locally; GitHub is a remote you push to and pull from.
  • Key terms: repository, remote, push, pull, clone, fork, pull request, issue.
  • Sign up with the same email as your Git config and turn on two-factor authentication.
  • Sign in from the terminal once with gh auth login or Git Credential Manager.

GitHub Examples

Each example shows the code, the output it produces and what each part does.

Example 1

Sign in with GitHub CLI

Terminal
gh auth login
Output
? Where do you use GitHub? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: 4F2A-9C1D
Press Enter to open github.com in your browser...
✓ Authentication complete.
✓ Logged in as samlee
Line-by-line explanation
  1. Line 1gh asks a few questions; the default answers are fine for beginners. You confirm the code in your browser, and from then on git push works without passwords.
Example 2

Reading a repository address

Text
https://github.com/samlee/portfolio
https://github.com/samlee/portfolio/issues
https://github.com/samlee/portfolio/pull/3
https://github.com/samlee/portfolio.git
Output
Repository "portfolio" owned by user "samlee"
Its list of issues
Pull request number 3
The address Git uses to clone or push
Line-by-line explanation
  1. Line 1Every repository lives at github.com/owner/name.
  2. Lines 2 to 3Issues and pull requests have their own pages, numbered in order.
  3. Line 4The same address ending in .git is used by Git commands such as git clone.
Example 3

A profile README

Create a public repository named exactly like your username and add this README.md:

Markdown
# Hi, I'm Sam

I'm learning web development and Python.

- Currently building: a recipe website
- Learning: Git, GitHub and SQL
- Ask me about: CSS layouts
Output
Hi, I'm Sam

I'm learning web development and Python.

• Currently building: a recipe website
• Learning: Git, GitHub and SQL
• Ask me about: CSS layouts
Line-by-line explanation
  1. Line 1# makes a large heading in Markdown, the format GitHub uses for README files.
  2. Lines 5 to 7Lines starting with - become a bulleted list on your profile page.

Common GitHub Mistakes

Using your password on the command line

Don't
git push
# Username: samlee
# Password: my-github-password   -> authentication failed
Do
gh auth login
git push

GitHub only accepts tokens, browser sign-in or SSH keys from Git, never your account password.

Mismatched commit email

Don't
git config --global user.email "old-school-email@example.com"
Do
git config --global user.email "the-email-on-your-github-account@example.com"

If the emails don't match, your commits won't be linked to your profile.

GitHub in Real Projects

GitHub in practice

Companies keep their private code on GitHub and review every change through pull requests. Open-source projects use issues to collect bug reports from users worldwide. Job applicants link their GitHub profile on their CV, and teachers use GitHub Classroom to hand out and collect assignments.

GitHub FAQ

Is GitHub free to use?

Yes. The free plan gives you unlimited public and private repositories, issues, pull requests and GitHub Actions, with a monthly allowance of Actions minutes for private repositories. Paid plans add extra features for teams and private repositories, but you don't need one to learn, build a portfolio or contribute to open source.

What is the difference between GitHub, GitLab and Bitbucket?

All three host Git repositories online and offer similar tools: pull requests (GitLab calls them merge requests), issues and automated pipelines. They differ in features, pricing and which tools they integrate with. The Git commands you learn work the same with all of them.

Can I change my GitHub username?

Yes, in your account settings. GitHub redirects links to your repositories from the old name, but links to your old profile page stop working, and someone else can later take the old username. Update the remote URLs in your local clones with git remote set-url so you don't rely on redirects.

Do I need to learn Git before using GitHub?

Not to get started. You can create repositories, edit files and open issues entirely in the browser. To work on projects on your own computer, though, you need the basic Git commands: clone, add, commit, push and pull.

Who owns GitHub?

GitHub has been owned by Microsoft since 2018. It still runs as its own service, and it hosts projects of every kind, including many that have nothing to do with Microsoft.

GitHub Exercises

Answer each one and check it instantly. If you get stuck, open the hint before the answer.

Fill in the blankseasy

Complete the GitHub CLI command that signs you in.

gh  
Multiple choiceeasy

What is a fork on GitHub?

Multiple choicemedium

Which statement about Git and GitHub is true?

Predict the outputmedium

What does https://github.com/ada/notes/pull/12 point to?

Multiple choicemedium

What's the main difference between Git and GitHub?

GitHub Quiz

5 questions to check what you learned.

  1. What does pushing do?

    • Downloads commits from GitHub
    • Deletes a branch
    • Sends your local commits to the remote repository
    • Creates a new repository
  2. Why should your Git email match your GitHub email?

    • Git won't work otherwise
    • To receive notifications
    • To make the repository public
    • So GitHub links your commits to your profile
  3. What is a profile README?

    • A README in a repo named after your username, shown on your profile
    • A README in every repository
    • Your account settings page
    • A private note
  4. Which of these can Git use to authenticate with GitHub?

    • Your GitHub account password
    • A browser sign-in through GitHub CLI or Git Credential Manager
    • Your email address alone
    • Your username alone
  5. Why turn on two-factor authentication?

    • A stolen password alone isn't enough to get into your account
    • It makes pushes faster
    • It's needed to create a README
    • It makes repositories private