🐙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
- Go to https://github.com
- Click Sign up
- Enter your email, create a password, and choose a username
- Verify your email address
- 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):
- Click the + icon in the top-right corner of GitHub
- Select New repository
- 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!
- Repository name:
- 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:
# 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
MITThe .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
cd /path/to/your-projectStep 3: Initialize Git (if not already done)
git init
git add .
git commit -m "Initial commit"Step 4: Add the remote and push
git remote add origin https://github.com/your-username/my-first-project.git
git branch -M main
git push -u origin mainLet's break that down:
| Command | What It Does |
|---|---|
git remote add origin <url> | Tells Git where your GitHub repo is |
git branch -M main | Renames your branch to main |
git push -u origin main | Uploads 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.
git clone https://github.com/username/repo-name.gitThis creates a folder called repo-name with all the code and history.
Example — clone a popular project:
git clone https://github.com/facebook/react.git
cd react
lsNow you have the entire React source code on your machine!
Clone with SSH (if configured):
git clone git@github.com:username/repo-name.gitForking — 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:
- Go to the repository page on GitHub
- Click the Fork button (top-right)
- GitHub creates a copy under your account:
github.com/original-author/project→github.com/your-username/project
After forking:
# 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 -vOutput:
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:
- You fork a project (or create a branch)
- You make your changes and commit them
- You push your changes
- You open a Pull Request on GitHub
- The project maintainer reviews your changes
- If approved, your changes get merged
Creating a PR (step by step):
-
Push your changes to your fork or branch:
git push origin my-feature-branch -
Go to the repository on GitHub
-
You'll see a yellow banner: "Compare & pull request" — click it
-
Fill in the PR form:
- Title: Short description of what you changed
- Description: Explain why you made the change and what it does
-
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:
- Go to the repository's Issues tab
- Click New issue
- Fill in the title and description
- Add labels (bug, enhancement, help wanted, etc.)
- Click Submit new issue
Referencing issues in commits:
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:
- Create a repo named
your-username.github.io - Add an
index.htmlfile - Push to GitHub
- 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):
name: Run Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm install
- run: npm testWe'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:
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:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Copy the public key:
# macOS
cat ~/.ssh/id_ed25519.pub | pbcopy
# Linux
cat ~/.ssh/id_ed25519.pub | xclip -selection clipboard
# Windows (Git Bash)
cat ~/.ssh/id_ed25519.pub | clipAdd to GitHub:
- Go to Settings → SSH and GPG keys → New SSH key
- Paste your key and save
Test the connection:
ssh -T git@github.comYou 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:
# 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 RequestPopular Repos to Explore
Here are some beginner-friendly repositories to explore on GitHub:
| Repository | What It Is |
|---|---|
freeCodeCamp/freeCodeCamp | Free coding curriculum |
EbookFoundation/free-programming-books | Free programming books |
firstcontributions/first-contributions | Practice making your first PR |
github/gitignore | Useful .gitignore templates |
sindresorhus/awesome | Curated list of awesome lists |
public-apis/public-apis | Free APIs for projects |
microsoft/vscode | VS Code source code |
facebook/react | React library source |
Try this right now:
- Visit
github.com/firstcontributions/first-contributions - Follow their guide to make your first contribution
- You'll practice forking, cloning, branching, and creating a PR
Common GitHub Mistakes
| Mistake | Solution |
|---|---|
| Pushing to the wrong remote | Check with git remote -v |
| Forgetting to fork first | Fork, then clone your fork |
| PR to wrong branch | Double-check the base branch in the PR |
| Large files in repo | Use .gitignore and Git LFS |
| Committing secrets | Never commit passwords or API keys! |
Quick Reference
# 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 mainWhat'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.