What Is a Pull Request? A Beginner's Guide to Code Review
A pull request is a proposal to merge one branch into another, reviewed by teammates first. Learn the step-by-step cycle, a description template, what reviewers check and the three merge methods.
Short answer: A pull request (PR) is a request to merge changes from one branch into another, with a page where teammates can see the exact changes, discuss them and approve them before they are merged. Pull requests are where most code review happens on platforms such as GitHub; GitLab calls the same idea a merge request.
What is a pull request and why do teams use it?
A pull request is a proposal: "here are my commits on this branch, please pull them into main". Instead of pushing straight into the shared branch, you push your own branch and open a pull request. The PR page shows the diff line by line, lets reviewers comment on specific lines, and runs automated checks such as tests.
Teams use pull requests for four reasons: a second person catches mistakes, the main branch stays working, automated tests run before anything is merged, and the PR leaves a written record of why a change was made. If branches and remotes are new to you, start with what Git and GitHub are.
How does a pull request work, step by step?
A pull request follows the same cycle in almost every team:
Create a branch for one change.
Commit your work and push the branch to GitHub.
Open a pull request: choose the base branch (where the change goes, usually
main) and the compare branch (your branch).Write a title and description, and request reviewers.
Reviewers comment, approve or request changes.
Push more commits to the same branch to fix things; the PR updates automatically.
When checks pass and reviewers approve, merge, then delete the branch.
The commands for steps 1 and 2 look like this. After the push, GitHub usually offers a button to open a pull request for the new branch, or you can use the GitHub CLI:
git switch -c fix-login-message # 1. new branch for one change
# ...edit login.py...
git add login.py
git commit -m "Show a clear message when the password is wrong"
git push -u origin fix-login-message # 2. send the branch to GitHub
gh pr create --fill # 3. optional: open the PR with GitHub CLIThe everyday commands are collected in 15 essential Git commands, and the course chapter on pull requests and your first published project walks through a full example.
What should a good pull request description include?
A good pull request description tells the reviewer what changed, why, and how to check it, so they do not have to guess. This short template works for most changes:
## What
Show a clear error message when the password is wrong.
## Why
Users saw a blank page and thought the site was down.
## How to test
1. Run the app and open the login page
2. Log in with a wrong password
3. You should see "Wrong email or password"
## Notes
No database changes. Screenshot attached.Keep each pull request to one purpose. A small PR with a clear description gets a careful review; a huge one tends to get a quick "looks good" that misses real problems.
What do reviewers look for in code review?
Code reviewers check whether a change is correct, understandable and safe to merge. A simple checklist:
Question | What to look at |
|---|---|
Does it work? | Logic, edge cases, error handling |
Can others read it? | Clear names, no dead code, comments where needed |
Is it tested? | New or updated tests, checks passing |
Is it safe? | No passwords or API keys in code, user input validated |
Is it focused? | Only changes related to the stated purpose |
Good review comments are specific and kind: "This fails if the list is empty; could we return early?" is better than "wrong". Reviewers can also mark small points as optional so the author knows what blocks the merge.
What are the ways to merge a pull request?
GitHub offers three merge methods for a pull request, and a repository can turn some of them off:
Method | What happens | History looks like |
|---|---|---|
Create a merge commit | All commits are kept, plus one merge commit | Full detail, branch structure visible |
Squash and merge | All commits are combined into one | One clean commit per PR |
Rebase and merge | Commits are replayed on top of the base branch | Straight line, no merge commit |
If the base branch has changed in the same lines as your branch, the PR shows a conflict that must be fixed first; see how to resolve a Git merge conflict.
Common mistakes
Giant pull requests that mix a feature, a refactor and formatting changes.
An empty description, leaving reviewers to work out the purpose.
Approving without reading just to unblock a teammate.
Taking review comments personally. The review is about the code, not the person.
Committing secrets. Once pushed, a key should be treated as leaked and replaced.
Interview tip: if asked how you work in a team, describe the cycle above: branch, small commits, a PR with a clear description, review, passing checks, merge. It shows you know how real teams ship code.
Frequently Asked Questions
Why is it called a pull request?
You are asking the owners of the main branch to pull your commits into it. GitLab uses the name merge request for the same thing, which describes the result instead of the action.
Can I open a pull request on my own repository?
Yes. Many solo developers open pull requests to themselves so that automated checks run and each change has its own description and history.
What is a draft pull request?
A draft pull request on GitHub is a PR marked as not ready yet. Others can see and comment on it, but it cannot be merged until you mark it ready for review.
What is the difference between a fork and a pull request?
A fork is your own copy of someone else's repository, while a pull request is the proposal to merge changes. In open source you usually fork a project, push a branch to your fork, and open a pull request back to the original.
Key Takeaway
A pull request is a reviewed proposal to merge one branch into another. Keep it small, explain what and why, respond to review calmly, and merge only when checks pass. GitHub's pull request documentation covers every option in detail.
Ready to start? You will learn Git branches, GitHub and pull requests step by step, and publish your first project. Begin with the free course Git, APIs and Backend for AI: Beginner.
Related articles
More in APIs and Backend
What Is a Webhook? Webhooks vs API Polling
A webhook is an HTTP request a service sends to your URL when an event happens. Compare webhooks with API polling and learn to verify webhook signatures in Python.
5 min readNov 30, 2026How to Resolve a Git Merge Conflict
A step-by-step guide to resolving a Git merge conflict, using a real conflict created from scratch, with the output at each step and how to cancel safely.
4 min readNov 26, 2026What Is Docker and Why Do AI Developers Use It?
Docker packs your app and everything it needs into a container that runs the same everywhere. Learn images, containers and Dockerfiles, and why AI developers rely on them.
4 min readNov 23, 2026FastAPI vs Flask vs Django for AI Apps
Which Python web framework should you use for an AI app? A plain comparison of FastAPI, Flask and Django, when each fits, and a tiny working endpoint.
4 min readNov 19, 202615 Essential Git Commands (Cheat Sheet)
The 15 Git commands you will use almost every day, each with a one-line purpose and an example, plus a daily workflow and common mistakes.
4 min readNov 17, 2026How to Keep API Keys Safe: .env Files and Secrets
Keep API keys out of your code: use .env files and environment variables, ignore them in Git, and know exactly what to do if a key leaks.
4 min readNov 14, 2026
Comments
Sign in to join the discussion.

