Skip to content
$ lynuxpro
← GitHub & GitHub Actions

LESSON 1 OF 19 · BEGINNER · 10 MIN

GitHub essentials

Free previewLesson 1 of the 2 free lessons in this Pro course.Unlock all 19

HOW IT WORKSFrom your laptop to GitHub

Your laptoplocal repo
1/5

Git keeps your project history on your own computer.

In simple words

  • GitHub: a website that hosts Git repositories and adds pull requests, issues, Actions and security tools.
  • Repository: a project's files and history.
  • Fork: your own copy of someone else's repository, so you can propose changes.
  • README / LICENSE: the front-page description of a repo, and the rules for using its code.

Big picture

Git is a tool on your computer that remembers every version of your files. GitHub is a website that stores your Git projects online, so a team can share them. Think of Git as a notebook and GitHub as the shared shelf where everyone leaves their notebooks.

The main ideas

WordPlain meaning
Repository (repo)A project folder with all its history, stored on GitHub
CloneCopy a repo from GitHub to your computer
ForkMake your own copy of someone else's repo on GitHub
READMEThe front page of the repo. It says what the project is
OrganizationA shared account for a company or team that owns repos
VisibilityPublic (everyone sees it) or private (only people you allow)

Create your first repo

gh repo create acme/app --private --clonecd appecho "# App" > README.mdgit add README.mdgit commit -m "Add README"git push -u origin main
SHELLbashutf-8 · 6L
✓ Created repository acme/app on GitHub✓ Cloned repository acme/app[main (root-commit) 3f2a1b9] Add README 1 file changed, 1 insertion(+)Branch 'main' set up to track 'origin/main'.
OUTPUTterminalutf-8 · 5L

gh is GitHub's command line tool. You can also click New repository on the website.

Sign in safely with SSH keys

An SSH key is a pair of files: a private key that stays on your laptop, and a public key that you give to GitHub. GitHub uses the pair to know it is really you, with no password.

ssh-keygen -t ed25519 -C "you@example.com"cat ~/.ssh/id_ed25519.pubssh -T git@github.com
SHELLbashutf-8 · 3L
Hi leela! You've successfully authenticated, but GitHub does not provide shell access.
OUTPUTterminalutf-8 · 1L

Paste the .pub file into Settings → SSH and GPG keys. Never share the file without .pub.

Fork and clone

Use a fork when you cannot write to a project, such as an open source one. Use clone when you can.

gh repo fork cli/cli --clone
SHELLbashutf-8 · 1L

Files every repo should have

FileWhy
README.mdWhat it is and how to run it
.gitignoreFiles Git must skip, like node_modules and secrets
LICENSEWhat others may do with your code
CONTRIBUTING.mdHow to help

Git in one minute

GitHub works with Git. These are the Git commands you will use every day:

CommandWhat it does
git statusShows which files changed
git add FILEPuts a change in the next save (a "commit")
git commit -m "message"Saves the change with a short note
git pushSends your commits to GitHub
git pullGets new commits from GitHub
git log --onelineShows the history
git log --oneline
SHELLbashutf-8 · 1L
3f2a1b9 Add READMEa91c0de Initial commit
OUTPUTterminalutf-8 · 2L

Each line is one saved version. The short code on the left is the commit's id.

Check that you are logged in

gh auth logingh auth statusgit config --global user.name "Leela"git config --global user.email "you@example.com"
SHELLbashutf-8 · 4L
github.com  ✓ Logged in to github.com account leela (keyring)  - Active account: true
OUTPUTterminalutf-8 · 3L

Git adds your name and email to every commit, so set them once.

Public or private?

ChoiceWho sees the codeGood for
PublicEveryoneOpen source, learning, portfolios
PrivateOnly people you inviteCompany code, anything with secrets
Internal (companies)Everyone in the companyShared company tools

Common mistakes

  • Committing passwords or .env files. Add them to .gitignore first.
  • Working directly on main. Use a branch (next lessons).
  • Sharing the private key instead of the public one.

Summary

  • GitHub stores Git repos online so teams can share them.
  • Clone to copy, fork to get your own copy of someone else's project.
  • SSH keys let you sign in without a password.
  • Start every repo with a README, .gitignore and a license.

CHECK YOUR UNDERSTANDING

3 quick questions

  1. 1. What is the difference between a clone and a fork?

  2. 2. Which key do you paste into GitHub for SSH sign-in?

  3. 3. What should go in .gitignore?