GitHub is where Git becomes collaborative. It hosts your repositories in the cloud and provides tools for code review, issue tracking, and project management.
Working with Remotes
A remote is a copy of your repository hosted on a server. When you clone a repo, Git automatically adds the source as a remote called origin:
# View configured remotes
git remote -v
# Add a remote
git remote add origin https://github.com/username/project.git
# Change the URL of a remote
git remote set-url origin https://github.com/username/new-project.git
Pushing and Pulling
Push sends your local commits to the remote:
# Push and set upstream tracking
git push -u origin main
# After tracking is set, just push
git pushPull fetches remote changes and merges them into your branch:
# Fetch and merge
git pull
# Fetch only (doesn't change your working directory)
git fetch
# Pull with rebase instead of merge
git pull --rebase
Use git fetch when you want to see what's new on the remote without modifying your local branches. Then inspect and merge manually if needed.
Pull Requests
A pull request (PR) is a proposal to merge one branch into another. It's the heart of collaboration on GitHub.
Creating a Pull Request
- Push your feature branch to GitHub:
git push -u origin feature/search-bar- Go to your repository on GitHub and click "Compare & pull request"
- Fill in the title and description
- Select reviewers and labels
- Click "Create pull request"
You can also create PRs from the command line with the GitHub CLI:
gh pr create --title "Add search bar" --body "Implements full-text search with filtering"Writing Good PR Descriptions
A good PR description helps reviewers understand the context:
## Summary
Add search functionality to the blog with full-text filtering.
## Changes
- Add SearchBar component with debounced input
- Implement search index using Fuse.js
- Add search results page with highlighted matches
## Testing
- Tested with 100+ blog posts
- Verified keyboard navigation works
- Tested on mobile and desktopCode Review
Code review catches bugs, shares knowledge, and maintains code quality.
As a Reviewer
- Read the PR description first to understand the goal
- Look at the overall approach before nitpicking details
- Be specific in feedback — suggest alternatives, not just "this is wrong"
- Approve when it's good enough, not when it's perfect
Requesting Changes
Leave comments on specific lines by clicking the + button next to any line in the diff. Use "Request changes" for blocking issues and "Comment" for suggestions.
Addressing Feedback
Push new commits to the same branch — the PR updates automatically:
# Make changes based on review feedback
git add src/search.js
git commit -m "Use debounced input for search"
git pushIssues
Issues track bugs, feature requests, and tasks:
# Create an issue with GitHub CLI
gh issue create --title "Search results don't highlight matches" --label "bug"
# List open issues
gh issue list
# Close an issue
gh issue close 42Linking Issues and PRs
Reference issues in commit messages or PR descriptions to link them:
git commit -m "Add search highlighting
Fixes #42"When the PR is merged, issue #42 will be closed automatically. Keywords that trigger auto-close: fixes, closes, resolves.
Forking and Contributing to Open Source
To contribute to a project you don't own:
- Fork the repository on GitHub (creates your own copy)
- Clone your fork locally:
git clone https://github.com/your-username/project.git
- Add the original repo as an upstream remote:
git remote add upstream https://github.com/original-owner/project.git
- Create a branch, make changes, push to your fork, and open a PR against the original repo.
Keep your fork up to date:
git fetch upstream
git switch main
git merge upstream/main
git push origin main