Github

What is GitHub?

GitHub is a cloud platform where you store Git repositories, collaborate with others, and manage projects.

Think of it as:

  • Git = version control tool
  • GitHub = place to share and collaborate on your code

1. Create an Account

Go to GitHub and sign up. Once logged in, you’ll have a dashboard where all your repositories live.

2. Create a Repository (Repo)

  1. Click “New repository”
  2. Choose:
    • Name (e.g., my-project)
    • Public or Private
  3. Click Create

3. Connect Your Local Project to GitHub

Inside your project folder:

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

Link to GitHub:

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

Now your code is online

4. Clone a Repository

Download a repo from GitHub:

git clone https://github.com/user/repo.git
cd repo

5. Daily Workflow with GitHub

After making changes locally:

git add .
git commit -m "Describe your changes"
git push

To get updates from others

git pull

6. Branches on GitHub

Create a branch:

git checkout -b feature-login
git push -u origin feature-login

Branches let you work without affecting the main project.

7. Pull Requests (PRs)

A Pull Request is how you propose changes.

Steps:

  1. Push your branch
  2. Go to GitHub
  3. Click “Compare & pull request”
  4. Add description
  5. Submit PR

Others can:

  • Review your code
  • Comment
  • Approve or request changes

8. Code Reviews

Team members can:

  • Comment on specific lines
  • Suggest improvements
  • Approve before merging

This keeps code quality high.

9. Issues (Task Tracking)

Use Issues to track:

  • Bugs
  • Features
  • Tasks

Example:

  • “Fix login bug”
  • “Add dark mode”

10. Forking (Open Source Work)

A fork is your own copy of someone else’s repo.

Steps:

  1. Click Fork on a repo
  2. Clone your fork
  3. Make changes
  4. Submit a Pull Request to the original repo

11. README File

A README.md explains your project:

  • What it does
  • How to install
  • How to use

Written in Markdown.

12. .gitignore

This file tells Git what NOT to upload:

node_modules/
.env
*.log

Key Concepts to Remember

  • Push = upload your changes
  • Pull = download updates
  • PR = propose changes
  • Issues = track work
  • Fork = copy someone else’s project

Quick Cheat Sheet

ActionCommand
Push codegit push
Get updatesgit pull
Clone repogit clone URL
New branchgit checkout -b name
Push branchgit push -u origin name