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)
- Click “New repository”
- Choose:
- Name (e.g.,
my-project) - Public or Private
- Name (e.g.,
- Click Create
3. Connect Your Local Project to GitHub
Inside your project folder:
git initgit add .git commit -m "Initial commit"
Link to GitHub:
git remote add origin https://github.com/your-username/my-project.gitgit branch -M maingit 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.gitcd 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-logingit 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:
- Push your branch
- Go to GitHub
- Click “Compare & pull request”
- Add description
- 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:
- Click Fork on a repo
- Clone your fork
- Make changes
- 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
| Action | Command |
|---|---|
| Push code | git push |
| Get updates | git pull |
| Clone repo | git clone URL |
| New branch | git checkout -b name |
| Push branch | git push -u origin name |