HomeTerminal & Command LineGitHub — Your Code in the Cloud
beginner12 min read· Module 3, Lesson 11

🐙GitHub — Your Code in the Cloud

Create repos, push code, fork projects, and understand pull requests

GitHub — Your Code in the Cloud

What Is GitHub?

Let's clear up the most common confusion right away:

  • Git is a version control tool that runs on your computer
  • GitHub is a website that hosts Git repositories in the cloud

Think of it this way: Git is like your camera, and GitHub is like Instagram. You take photos (commits) with your camera (Git), then upload them to Instagram (GitHub) so other people can see and collaborate.

GitHub is not the only hosting platform — there's also GitLab, Bitbucket, and others — but GitHub is by far the most popular, with over 100 million developers.


Creating a GitHub Account

  1. Go to https://github.com
  2. Click Sign up
  3. Enter your email, create a password, and choose a username
  4. Verify your email address
  5. You now have a GitHub account!

Choosing a username: Pick something professional — this will be part of your public profile URL. For example: github.com/your-username


Creating Your First Repository

A repository (or repo) is a project folder on GitHub.

Step-by-step (using the web UI):

  1. Click the + icon in the top-right corner of GitHub
  2. Select New repository
  3. Fill in the details:
    • Repository name: my-first-project
    • Description: My first GitHub repository
    • Visibility: Public (anyone can see) or Private (only you)
    • Initialize with a README: Check this box!
  4. Click Create repository

That's it! You now have a repository on GitHub.


README.md — Every Project Needs One

When you visit any repository on GitHub, the first thing you see is the README.md file rendered on the page.

What goes in a README?

  • Project name and description
  • How to install the project
  • How to use it
  • How to contribute (if open source)
  • License information

Example README:

Markdown
# My First Project A simple project to learn GitHub. ## Installation \`\`\`bash git clone https://github.com/your-username/my-first-project.git cd my-first-project \`\`\` ## Usage Open \`index.html\` in your browser. ## License MIT

The .md extension stands for Markdown — a simple formatting language that GitHub renders into nice HTML.


Connecting a Local Project to GitHub

You have a project on your computer and a new empty repo on GitHub. Here's how to connect them:

Step 1: Create a repo on GitHub (without README)

When creating the repo, do not check "Initialize with a README" this time.

Step 2: In your terminal, navigate to your project

Terminal
cd /path/to/your-project

Step 3: Initialize Git (if not already done)

Terminal
git init git add . git commit -m "Initial commit"

Step 4: Add the remote and push

Terminal
git remote add origin https://github.com/your-username/my-first-project.git git branch -M main git push -u origin main

Let's break that down:

CommandWhat It Does
git remote add origin <url>Tells Git where your GitHub repo is
git branch -M mainRenames your branch to main
git push -u origin mainUploads your code to GitHub

The -u flag sets up tracking, so next time you can just type git push.


Cloning a Repository

Cloning means downloading someone else's (or your own) repo to your computer.

Terminal
git clone https://github.com/username/repo-name.git

This creates a folder called repo-name with all the code and history.

Example — clone a popular project:

Terminal
git clone https://github.com/facebook/react.git cd react ls

Now you have the entire React source code on your machine!

Clone with SSH (if configured):

Terminal
git clone git@github.com:username/repo-name.git

Forking — Your Own Copy

Forking creates your own copy of someone else's repository under your GitHub account.

Why fork?

  • You want to modify someone else's project
  • You want to contribute to an open source project
  • You want to experiment without affecting the original

How to fork:

  1. Go to the repository page on GitHub
  2. Click the Fork button (top-right)
  3. GitHub creates a copy under your account: github.com/original-author/projectgithub.com/your-username/project

After forking:

Terminal
# Clone YOUR fork (not the original) git clone https://github.com/your-username/project.git cd project # Add the original repo as "upstream" git remote add upstream https://github.com/original-author/project.git # Check your remotes git remote -v

Output:

origin https://github.com/your-username/project.git (fetch) origin https://github.com/your-username/project.git (push) upstream https://github.com/original-author/project.git (fetch) upstream https://github.com/original-author/project.git (push)

Now you have two remotes:

  • origin = your fork
  • upstream = the original project

What Is a Pull Request (PR)?

A Pull Request is how you propose changes to a repository. It says: "Hey, I made some changes — would you like to pull them into your project?"

The PR workflow:

  1. You fork a project (or create a branch)
  2. You make your changes and commit them
  3. You push your changes
  4. You open a Pull Request on GitHub
  5. The project maintainer reviews your changes
  6. If approved, your changes get merged

Creating a PR (step by step):

  1. Push your changes to your fork or branch:

    Terminal
    git push origin my-feature-branch
  2. Go to the repository on GitHub

  3. You'll see a yellow banner: "Compare & pull request" — click it

  4. Fill in the PR form:

    • Title: Short description of what you changed
    • Description: Explain why you made the change and what it does
  5. Click Create pull request

PR best practices:

  • Keep PRs small and focused — one feature or fix per PR
  • Write a clear description of what and why
  • Reference related issues (e.g., "Fixes #42")
  • Add screenshots if there are visual changes
  • Respond to review comments promptly

GitHub Issues

Issues are GitHub's built-in bug tracker and task manager.

Types of issues:

  • Bug reports: "The login button doesn't work on mobile"
  • Feature requests: "Add dark mode support"
  • Questions: "How do I configure the API key?"
  • Tasks: "Update dependencies to latest versions"

Creating an issue:

  1. Go to the repository's Issues tab
  2. Click New issue
  3. Fill in the title and description
  4. Add labels (bug, enhancement, help wanted, etc.)
  5. Click Submit new issue

Referencing issues in commits:

Terminal
git commit -m "Fix login button on mobile — closes #42"

The keywords closes, fixes, or resolves followed by #issue-number will automatically close the issue when the PR is merged.


GitHub Pages — Free Website Hosting

GitHub can host static websites for free using GitHub Pages.

Quick setup:

  1. Create a repo named your-username.github.io
  2. Add an index.html file
  3. Push to GitHub
  4. Visit https://your-username.github.io

Your website is live! This is perfect for:

  • Personal portfolios
  • Project documentation
  • Simple web apps

We'll cover this in more detail in a later lesson.


GitHub Actions — Brief Mention

GitHub Actions lets you automate tasks in your repository:

  • Run tests automatically when you push code
  • Deploy your website when you merge to main
  • Check code quality on every pull request

Example workflow file (.github/workflows/test.yml):

YAML
name: Run Tests on: [push] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npm install - run: npm test

We'll cover GitHub Actions in depth in a later module.


SSH Keys Setup

Using SSH keys lets you push to GitHub without entering your password every time.

Generate an SSH key:

Terminal
ssh-keygen -t ed25519 -C "your-email@example.com"

Press Enter for all prompts (default location and no passphrase for simplicity).

Add the key to your SSH agent:

Terminal
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519

Copy the public key:

Terminal
# macOS cat ~/.ssh/id_ed25519.pub | pbcopy # Linux cat ~/.ssh/id_ed25519.pub | xclip -selection clipboard # Windows (Git Bash) cat ~/.ssh/id_ed25519.pub | clip

Add to GitHub:

  1. Go to SettingsSSH and GPG keysNew SSH key
  2. Paste your key and save

Test the connection:

Terminal
ssh -T git@github.com

You should see: Hi username! You've successfully authenticated...


The GitHub Flow

This is the standard workflow used by millions of developers:

1. Fork the repo (or create a branch) ↓ 2. Clone to your machine ↓ 3. Create a new branch ↓ 4. Make changes and commit ↓ 5. Push to GitHub ↓ 6. Open a Pull Request ↓ 7. Code review and discussion ↓ 8. Merge into main

Full example:

Terminal
# 1. Fork on GitHub (click the button), then clone git clone https://github.com/your-username/awesome-project.git cd awesome-project # 2. Create a branch git checkout -b fix-typo # 3. Make your changes # (edit files...) # 4. Stage and commit git add . git commit -m "Fix typo in README" # 5. Push your branch git push origin fix-typo # 6. Go to GitHub and open a Pull Request

Popular Repos to Explore

Here are some beginner-friendly repositories to explore on GitHub:

RepositoryWhat It Is
freeCodeCamp/freeCodeCampFree coding curriculum
EbookFoundation/free-programming-booksFree programming books
firstcontributions/first-contributionsPractice making your first PR
github/gitignoreUseful .gitignore templates
sindresorhus/awesomeCurated list of awesome lists
public-apis/public-apisFree APIs for projects
microsoft/vscodeVS Code source code
facebook/reactReact library source

Try this right now:

  1. Visit github.com/firstcontributions/first-contributions
  2. Follow their guide to make your first contribution
  3. You'll practice forking, cloning, branching, and creating a PR

Common GitHub Mistakes

MistakeSolution
Pushing to the wrong remoteCheck with git remote -v
Forgetting to fork firstFork, then clone your fork
PR to wrong branchDouble-check the base branch in the PR
Large files in repoUse .gitignore and Git LFS
Committing secretsNever commit passwords or API keys!

Quick Reference

Terminal
# Connect local project to GitHub git remote add origin https://github.com/user/repo.git git push -u origin main # Clone a repo git clone https://github.com/user/repo.git # Fork workflow # 1. Fork on GitHub # 2. Clone your fork git clone https://github.com/your-user/repo.git # 3. Add upstream git remote add upstream https://github.com/original/repo.git # 4. Create branch, make changes, push git checkout -b my-feature git add . git commit -m "Add feature" git push origin my-feature # 5. Open PR on GitHub # Keep your fork up to date git fetch upstream git checkout main git merge upstream/main git push origin main

What's Next?

Now that you understand GitHub, you can:

  • Host your projects in the cloud
  • Collaborate with other developers
  • Contribute to open source projects
  • Build your portfolio with public repos

In the next lessons, we'll dive deeper into branching strategies, resolving merge conflicts, and using GitHub Actions for automation.