What is a Pull Request?
A pull request (PR) is a request to merge your branch into main. It enables code review and team discussion before integration.
The Flow
Your Branch → Create PR → Review → Approve → Merge
Creating a Pull Request
Push Your Branch
git checkout -b feature/search
# ... make commits ...
git push -u origin feature/searchCreate PR on GitHub/GitLab
GitHub:
- Go to repository
- Click "Pull Requests"
- Click "New Pull Request"
- Select: base = main, compare = feature/search
- Add title and description
GitLab:
- Code → Merge Requests
- New Merge Request
- Select source/target branches
- Describe the change
PR Title and Description
Good PR Title:
Add search box to homepage
Implement autocomplete for search feature
Fix race condition in payment processing
PR Description Template:
## What does this PR do?
Adds search functionality to homepage with autocomplete suggestions.
## Why?
Users want quick access to find content.
## How to test?
1. Click search box
2. Type "hello"
3. See autocomplete suggestions
4. Click one to search
## Related Issues
Closes #432Reviewing Pull Requests
Code Review Checklist
- ✅ Code follows style guide
- ✅ No security vulnerabilities
- ✅ Functions are well-named
- ✅ Tests added for new functionality
- ✅ Documentation updated if needed
- ✅ No hardcoded values or debug code
- ✅ Performance acceptable
Commenting on Code
For specific code sections:
# In diff view, click line to comment
# Example comment:
"This function is doing too much. Maybe split into
smaller functions for better readability?"Approving vs. Requesting Changes
- Approve: Code looks good, ready to merge
- Request Changes: Needs fixes before merge
- Comment: General feedback, not blocking
Addressing Feedback
Respond to Comments
# Make changes based on feedback
git add fixed-file.ts
git commit -m "Clean up function as requested in review"
# Push to same branch
git push
# PR automatically updates with new commitResolving Comments
After making requested changes:
- Comment: "Done" or cross out comment
- Some platforms allow "Resolve" button
PR Status Checks
Automated Checks
Common CI/CD checks that run on PR:
- ✅ Build succeeds
- ✅ Tests pass
- ✅ Linter passes
- ✅ Code coverage above threshold
- ✅ No security vulnerabilities
# In PR status:
All checks passing → Ready to merge ✅
Build failing → Fix and push → Re-run checksFailing Checks
If check fails:
# Fix locally
npm run build # or npm test, npm run lint
git add .
git commit -m "Fix build error"
git push
# Checks automatically re-run on GitHubMerging Pull Requests
Merge Methods
| Method | Result | Use |
|---|---|---|
| Create merge commit | Merge commit created | Official record |
| Squash and merge | Single commit | Clean history |
| Rebase and merge | Linear history | Fast-forward |
Merge Process
Interactive:
- Click "Merge pull request"
- Choose merge method
- Confirm
Command line:
# Review changes
git diff main feature/auth
# Merge locally
git checkout main
git pull
git merge --no-ff feature/auth
# Push
git pushAfter Merge
Delete the feature branch:
# Local
git branch -d feature/auth
# Remote (or delete via GitHub UI)
git push origin --delete feature/authAdvanced PR Workflows
Draft Pull Requests
For work-in-progress:
- Click "Mark as draft" before ready
- CI/CD usually skipped
- Signals "not ready for review"
git push origin feature/wip
# Create PR but mark as DRAFTRequesting Reviewers
# On GitHub
Assignees → Select team members
Reviewers → Select who should review
# GitHub notifies themPR Conversation
## Reviewer
"This logic seems inefficient - did you consider caching?"
## Author
"Good catch! Updated to cache results.
Benchmarks show 40% improvement. Check commit abc1234."
## Reviewer
"✅ Looks great now"Common PR Mistakes
❌ Too Large
PR with 500+ lines changed.
Fix: Break into smaller, focused PRs.
❌ No Description
PR with title "Update" and empty description.
Fix: Describe what, why, and how to test.
❌ Unrelated Changes
PR claims to fix bug but includes refactoring.
Fix: One logical change per PR.
❌ Ignoring Feedback
Pushing same code after review comments.
Fix: Address feedback or discuss why not changing.
Workflow: Complete PR Cycle
# 1. Create feature branch
git checkout -b feature/notifications
git add notification.ts
git commit -m "Add email notifications"
# 2. Push and create PR
git push -u origin feature/notifications
# Go to GitHub → Create PR
# 3. Wait for review
# Reviewer checks code
# 4. Address feedback
git add notification.ts
git commit -m "Add error handling as requested"
git push
# 5. Get approval + tests pass
# Click "Merge pull request"
# 6. Delete branch
git push origin --delete feature/notificationsTips
✓ One logical change per PR
✓ Write clear, descriptive titles
✓ Add context in description
✓ Keep PRs small (100-400 lines)
✓ Respond to feedback respectfully
✓ Don't force-push after PR created
✓ Clean up branches after merge