GitHub Pull Request
GitHub Pull Request: Reviewing Code Before Merging to main
A Pull Request (PR) proposes merging commits from your feature branch (or fork) into a target branch such as main. Pull requests give teams a dedicated space to inspect diffs line by line, run automated tests, discuss architecture choices, and catch bugs before code reaches production.
Preparing and Opening a Pull Request
Start by pushing a focused feature branch containing clean, tested commits:
git switch -c feature/header-nav
git add index.html styles.css assets/banner.svg
git commit -m "Add responsive header navigation and banner.svg"
git push -u origin feature/header-nav
Open the repository on GitHub and click Compare & pull request:
- Verify the base branch (
main) and compare branch (feature/header-nav). - Write a clear title summarizing the change, such as
Add responsive header navigation. - Fill out the description with what changed, why, and how you tested it (plus screenshots for UI updates).
- Assign reviewers and click Create pull request (or Create draft pull request if still in progress).
Updating a PR After Review Feedback
You do not need to close and recreate a PR when a reviewer requests edits. Simply commit the fixes on the same local branch and push—GitHub updates the PR diff automatically:
git add styles.css
git commit -m "Increase mobile header link tap target size"
git push
Choosing Merge, Squash, or Rebase on GitHub
When tests pass and reviewers approve, GitHub offers three merge buttons:
- Create a merge commit: Preserves every individual branch commit plus a merge commit.
- Squash and merge: Combines all PR commits into a single clean commit on
main. - Rebase and merge: Replays each PR commit linearly onto
mainwithout a merge commit.
Common Pull Request Mistakes
Opening massive 2,000-line pull requests that mix refactoring, formatting, and feature work overwhelms reviewers and delays feedback. Keep each PR small and focused on one task.
Frequently Asked Questions
How do I resolve merge conflicts shown on a GitHub Pull Request?
Switch to your feature branch locally, run git fetch origin && git merge origin/main, fix the conflicting files in your editor, commit the resolution, and run git push.
What is a Draft Pull Request?
A Draft PR lets you share early progress and run CI checks without allowing anyone to merge it yet. Click Ready for review once your work is finished.
Can I close a pull request without merging it?
Yes. Click Close pull request at the bottom of the PR conversation if the approach is no longer needed.
Unlock Your
Full Potential.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With