Pull requests are how teams on GitHub propose, discuss, test and merge changes. In this lesson you will open your first pull request, write a description reviewers love, update it after feedback and merge it the right way.
📖 What You’ll Learn: what pull requests are, the full PR workflow, opening a PR and its fields, writing a good description, draft PRs, the PR tabs, updating a PR and handling an out-of-date branch, the three merge methods, PRs with the GitHub CLI, and best practices.
🔃 What Is a Pull Request?
A pull request (PR) is a request to merge the changes from one branch into another, usually from a feature branch into main. It is the heart of teamwork on GitHub:
- Teammates review the code and discuss it line by line.
- Automated checks (tests, linting, builds) run on the changes in GitHub Actions.
- The change is merged only when it is approved and the checks pass.
Pull requests also create a permanent record of why a change was made.
🧭 The Pull Request Workflow
1. Create a branch git switch -c feature/login-tests
2. Commit your changes git commit -m "Add login tests for locked-out users"
3. Push the branch git push -u origin feature/login-tests
4. Open a pull request on GitHub (or gh pr create)
5. Review and checks teammates comment, CI runs
6. Update if needed more commits on the same branch update the PR
7. Merge squash, merge commit or rebase
8. Clean up delete the branch
Steps 1 to 3 are covered in Git Branches and clone, push and pull.
📝 Step 1: Open the Pull Request
After you push a branch, GitHub shows a yellow banner with Compare & pull request. Click it (or open Pull requests, New pull request and choose the branches).
| Field | What to fill in |
|---|---|
| base | The branch you want to merge into (usually main) |
| compare | Your feature branch |
| Title | A short summary, e.g. “Add login tests for locked-out users” |
| Description | What changed, why, how it was tested, screenshots, and linked issues |
| Reviewers | Teammates who should review |
| Assignees | Who is responsible for the PR (usually you) |
| Labels | e.g. tests, bug, enhancement |
A good PR description
## What
Adds login tests for locked-out and invalid users.
## Why
Locked-out users were not covered; see the bug in #42.
## How it was tested
- Ran npx playwright test tests/login.spec.ts in Chromium and Firefox
- All 6 tests pass locally and in CI
Closes #42
Writing Closes #42 (or Fixes or Resolves) links the PR to issue 42 and closes the issue automatically when the PR is merged into the default branch. See Issues and Projects. Teams often provide this structure with a pull request template.
✍️ Draft Pull Requests
Not ready for review but want feedback or CI results? Choose Create draft pull request from the dropdown on the green button. When finished, click Ready for review.
🔍 Step 2: The PR Page
| Tab | Shows |
|---|---|
| Conversation | Description, comments, review summary, checks and the merge box |
| Commits | Every commit on the branch |
| Checks | Results of GitHub Actions and other CI |
| Files changed | The diff, where reviewers comment line by line (code review) |
🔁 Step 3: Update the PR After Feedback
Just commit and push to the same branch; the PR updates automatically:
# fix the review comments, then:
git add tests/login.spec.ts
git commit -m "Use getByRole for the login button"
git push
If main moved on and the PR shows “This branch is out-of-date with the base branch”, click Update branch on GitHub, or locally:
git fetch
git rebase origin/main # or: git merge origin/main
git push --force-with-lease # needed after a rebase
Conflicts? GitHub can resolve simple ones in the browser with Resolve conflicts; otherwise resolve them locally (merge conflicts).
✅ Step 4: Merge the Pull Request
The merge box offers up to three methods (repository admins choose which are allowed):
| Button | What happens | History on main |
|---|---|---|
| Create a merge commit | All branch commits plus a merge commit | Complete, shows the branch |
| Squash and merge | All branch commits combined into one commit | One clean commit per PR |
| Rebase and merge | Branch commits replayed on top of main, no merge commit | Linear, keeps every commit |
Many teams use Squash and merge so each PR becomes one readable commit on main. Background: git merge and git rebase.
After merging, click Delete branch, then clean up locally:
git switch main
git pull
git branch -d feature/login-tests
git fetch --prune
⌨️ Pull Requests from the Terminal
With the GitHub CLI:
gh pr create --title "Add login tests" --body "Closes #42" --reviewer teammate
gh pr list
gh pr checkout 57 # check out someone else's PR locally to test it
gh pr merge 57 --squash --delete-branch
💡 Tip: As a tester, gh pr checkout <number> is the fastest way to run a developer’s branch locally and test it before it is merged.
✅ Pull Request Best Practices
- Small PRs: under about 400 changed lines are reviewed faster and better.
- One purpose per PR: do not mix a bug fix, a refactor and a new feature.
- Clear title and description, with testing notes and screenshots for UI changes.
- Green checks before asking for review.
- Respond to every comment, then mark conversations resolved.
- Protect
mainso changes can only arrive through reviewed PRs (branch protection).
📝 Assignment
- In your
git-practicerepository on GitHub, create a branch, commit a change, push it and open a pull request with a good description. - Open a second PR as a draft, then mark it ready for review.
- Add a new commit to the first PR and watch it update.
- Create an issue, then open a PR with
Closes #<number>and merge it with Squash and merge; confirm the issue closed. - Make
mainmove ahead, then update an open PR’s branch with Update branch or a local rebase. - Bonus: install the GitHub CLI and create and merge a PR with
gh pr createandgh pr merge.
❓ FAQ
🤔 What is a pull request in GitHub?
A request to merge changes from one branch into another, with a place for discussion, code review and automated checks before the merge.
🤔 How do I create a pull request?
Push your branch, click Compare & pull request on GitHub (or Pull requests, New pull request), choose base and compare branches, add a title and description, and click Create pull request.
🤔 What is the difference between squash and merge and rebase and merge?
Squash and merge combines all PR commits into one commit on the base branch. Rebase and merge replays each commit on top of the base branch without a merge commit.
🤔 How do I update a pull request?
Push new commits to the same branch. The PR updates automatically.
🤔 How do I link a pull request to an issue?
Write Closes #<issue-number> in the PR description; the issue closes when the PR is merged into the default branch.
🎯 Next Steps
- 👀 Code Review on GitHub
- 🍴 Fork a Repository and Contribute to Open Source
- 📘 Git and GitHub Tutorial: full course
🎬 Learn Git and GitHub step by step: watch the series on YouTube!
Subscribe to SqaToolsByDY • Practice on sqatools.in
5 thoughts on “GitHub Pull Requests Step by Step: Create, Review, Update and Merge”