GitHub Pull Requests (PRs)
The complete Pull Request workflow: branch creation, commits, opening PRs, review requests, draft PRs, and merge strategies.
GitHub Pull Requests (PRs)
A Pull Request (PR) lets you notify team members about changes you've pushed to a branch in a repository on GitHub. Once a PR is opened, collaborators can review code, discuss proposed changes, run automated test suites (CI), and approve merging into main.
1. The Complete End-to-End PR Workflow
[ 1. Switch to main & pull ] ──► [ 2. Create feature branch ] ──► [ 3. Make commits ]
│
[ 6. Merge & Delete branch ] ◄── [ 5. CI Passes & Approved ] ◄── [ 4. Push & Open PR ]Step 1: Create a Feature Branch
git switch main
git pull origin main
git switch -c feat/search-filterStep 2: Make and Commit Changes
git add .
git commit -m "feat: add technology filter tags to search API"Step 3: Push Branch to GitHub
git push -u origin feat/search-filterStep 4: Open Pull Request
Navigate to the repository on GitHub or use the GitHub CLI:
gh pr create --title "feat: add technology filter tags to search API" --body "Closes #84"2. Draft Pull Requests
If your work is in progress and you want early design feedback or want to trigger CI checks without asking for formal reviews:
- Create the PR as a Draft.
- Draft PRs prevent accidental merges until you click Ready for review.
3. Merge Strategies on GitHub
When merging a PR, GitHub offers three options:
- Create a merge commit (
--no-ff): Preserves the complete commit history and creates a merge commit. - Squash and merge (
--squash): Collapses all PR commits into a single atomic commit onmain. Keeps main history linear and readable. - Rebase and merge (
--rebase): Re-applies individual commits on top ofmainwithout creating a merge commit.
Related Topics
GitHub Issues & Project Tracking
Managing project tasks with GitHub Issues: bug reports, feature requests, issue templates, labels, milestones, and closing issues via commits.
The Open-Source Fork Workflow
Contributing to open-source via forks: forking on GitHub, configuring upstream remotes, syncing main, and opening cross-repo pull requests.