1. What Is GitHub?
GitHubis the world's leading cloud hosting platform for software development and version control using Git. It provides a web interface where millions of developers store code repositories, review pull requests, report bugs with issues, and automate CI/CD pipelines.
2. Git vs GitHub
| Dimension | Git | GitHub |
|---|---|---|
| Definition | Command-line version control software | Cloud platform & collaboration hub |
| Execution | Runs locally on your laptop / PC | Runs in the cloud (web browsers & APIs) |
| Internet | 100% offline capable | Requires internet to sync & review |
| Key Power | Local snapshots, branches, diffs | Pull Requests, Code Review, CI/CD, Issues |
3. Creating a GitHub Account & SSH Keys
Sign up on github.com. Set up an SSH Key or GitHub Personal Access Token (PAT) so your terminal can securely push code without typing your password every time:
ssh-keygen -t ed25519 -C "your.email@example.com"
# Copy public key and paste into GitHub Settings ➔ SSH Keys
cat ~/.ssh/id_ed25519.pub
4. Understanding a GitHub Repository Anatomy
The front door of your repo. Explains the project, installation, screenshots, and usage.
Lists files Git must NEVER track (e.g. .env, node_modules/, build artifacts).
Defines legal permissions (MIT = permissive, Apache 2.0 = patent grant, GPL = copyleft).
5. Creating and Managing a Repository
You can start by creating a repo on GitHub and cloning it, OR connecting an existing local repo:
git clone https://github.com/username/repo-name.git
# Option B: Link an existing local project to GitHub
git remote add origin https://github.com/username/repo-name.git
git branch -M main
git push -u origin main
6. Working With Remote Repositories
Uploads local commits to the remote branch on GitHub.
Downloads remote changes and immediately merges them into your active branch.
Downloads remote branches to local cache without modifying your working files.
7. Branches on GitHub
GitHub visually displays all active branches. You can set branch protection rules on main requiring PR approvals and passing CI tests before anyone can merge.
8. Pull Requests (PRs) & Code Review
The Pull Request (PR)is GitHub's most important feature. It allows engineers to inspect changes, discuss architecture, suggest specific line edits, and approve before code lands in production:
Propose merging feature/login into main with a summary of changes.
Teammates review diffs, leave comments, and request adjustments.
Once approved & tests pass, merge with one click and delete the feature branch.
9. Issues, Labels & Project Tracking
Use GitHub Issues as your team's backlog. Add labels like bug, enhancement, good first issue, assign developers, and link issues directly to PRs by typing "Closes #12" in PR descriptions.
10. GitHub Collaboration & Open Source (Forks)
To contribute to an open-source project where you don't have write access:
# 2. Clone your fork locally
git clone https://github.com/your-username/open-source-repo.git
# 3. Create feature branch, make commits, and push to your fork
git switch -c fix/typo
git commit -m "fix: correct typo in auth docs"
git push origin fix/typo
# 4. Open a Pull Request from your fork back to the upstream repo!
11. GitHub Actions (CI/CD Basics)
name: Node CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm install && npm test
12. GitHub Pages (Free Web Hosting)
Host static frontends (HTML, CSS, JS, React/Vite builds) directly from your repository for free at https://username.github.io/repository-name under Repo Settings ➔ Pages.
13. GitHub Profile & Portfolio README
Create a repository with your exact username (e.g. username/username) with a special README.md to showcase your bio, tech stack badges, pinned repositories, and contribution activity graphs to recruiters.
14. A Complete Production GitHub Workflow
2. git switch -c feature/42-user-profile
3. Write code, test locally, commit atomically
4. git push -u origin feature/42-user-profile
5. Open Pull Request on GitHub (link to "Closes #42")
6. CI automated checks pass (GitHub Actions)
7. Code Review by teammate ➔ Approved
8. Merge PR into main ➔ Auto-deploy to production!
15. Common GitHub Mistakes
- Pushing secret API keys or credentials: Once pushed, commit history is public. Always use
.envand.gitignore. - Creating massive 2,000-line Pull Requests: Keep PRs small (< 300 lines) so teammates can review them quickly.
- Merging PRs with failing CI checks: Never bypass automated unit test failures.
- Not writing PR descriptions: Always explain what changed and why.
16. GitHub Best Practices
- Enable Branch Protection Rules on
main(require 1 approval + green CI). - Use Conventional Commits & PR titles (e.g.,
feat:,fix:,docs:). - Keep your GitHub profile active with polished READMEs and pinned projects.
- Delete merged feature branches to keep the repository clean.