Introduction to GitHub
What is GitHub?
GitHub is a web platform that hosts Git repositories online. It adds collaboration features on top of Git:
| Feature | What It Does |
|---|
| Remote repos | Store your code in the cloud |
| Pull Requests | Propose and review changes |
| Issues | Track bugs and feature requests |
| Actions | Automate testing and deployment |
| Pages | Host websites for free |
Local vs Remote
Your Computer (Local) GitHub (Remote)
┌──────────────┐ ┌──────────────┐
│ my-project/ │ ──push──> │ my-project │
│ .git/ │ <──pull── │ (hosted) │
└──────────────┘ └──────────────┘
- push = send your commits to GitHub
- pull = download others' commits from GitHub
- clone = download an entire repo for the first time
Key Commands
# Clone a repo from GitHub
git clone https://github.com/username/repo.gitConnect local repo to GitHub
git remote add origin https://github.com/username/repo.gitPush your commits
git push origin mainPull latest changes
git pull origin main
Creating a GitHub Repository
- Go to github.com and sign in
- Click the + button → New repository
- Name your repo, add a description
- Choose Public or Private
- Click Create repository
- Follow the instructions to push your local code
Alternatives to GitHub
| Platform | Notes |
|---|
| GitLab | Popular for DevOps, self-hostable |
| Bitbucket | Integrates with Atlassian tools |
| Codeberg | Open-source, non-profit |
They all use Git — the commands are the same!Summary
| Command | Purpose |
|---|
| <code>git clone URL</code> | Download a repo |
| <code>git remote add origin URL</code> | Link local to remote |
| <code>git push origin main</code> | Upload commits |
| <code>git pull origin main</code> | Download new commits |