The pull request workflow on GitHub
A pull request asks to merge your branch into another one, with review and automated checks in between. This is the whole loop: branch, push, open, update, merge, clean up.
Not checked by a trusted editor yet Last edited Outdated?
A pull request (PR) is a GitHub page that says “please merge branch A into branch B”. It shows the diff, collects review comments, and runs any automated checks you have set up. Most teams protect main so every change arrives through one.
1. Start from an up-to-date main
git switch main
git pull
2. Make a branch and commit
git switch -c feature/search
# ...edit, test...
git add .
git commit -m "Add search box to the header"
Name branches after the work, such as fix/cart-total or feature/search. Smaller PRs get reviewed faster and more carefully.
3. Push the branch
git push -u origin feature/search
-u links your local branch to the remote one, so later you can just type git push.
4. Open the pull request
After the push, GitHub shows a Compare & pull request button on the repository page. Choose the base branch (where it should go, usually main) and the compare branch (yours). With the GitHub CLI you can do it from the terminal:
gh pr create --fill # title and body from your commits
gh pr create --draft # open as a draft, not ready for review yet
A good description says what changed, why, and how to test it. Link the issue it solves; writing Closes #42 in the description closes issue 42 automatically when the PR is merged into the default branch.
5. Respond to review
Reviewers leave comments on lines and either approve or request changes. Fix things with new commits on the same branch and push; the PR updates by itself.
git add search.js
git commit -m "Debounce search input"
git push
6. Keep the branch current
If main moves on, bring your branch up to date. Merging is simplest; rebasing gives a cleaner history but rewrites your branch, so it needs a lease-protected force push:
git fetch origin
git rebase origin/main
git push --force-with-lease
If a teammate pushed to your branch in the meantime, --force-with-lease refuses instead of erasing their work. Pull their commits and try again.
7. Merge and clean up
Once checks pass and the PR is approved, press the merge button. GitHub can offer a merge commit, Squash and merge (all commits become one), or Rebase and merge, depending on the repository settings. Then tidy up locally:
git switch main
git pull
git fetch --prune
git branch -d feature/search
After a squash or rebase merge, Git cannot tell that your local branch was merged, because the commits on main are new ones. git branch -d then refuses with not fully merged. Check the PR really is merged, then use git branch -D.
Reviewing someone else's PR
gh pr checkout 123
gh pr view 123 --web
Running the branch yourself catches problems a diff alone hides. When you comment, explain the reason, and mark small style notes as optional so the author knows what blocks the merge.
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
See also
- 0262 Make your first pull request: Git and GitHub from first commit to merged change A complete beginner's path through Git and GitHub: set up Git, make commits, ignore files, use branches, push to GitHub, open a… Beginner · Guided project · Any system Article Branching & rebasing · Pull requests · Setup 15 Oct 2026
- 0314 What is a pull request? A pull request asks teammates to review and merge the changes on your branch into the main branch. Beginner · Explains an idea · Any system Article Pull requests 15 Oct 2026
- 0315 What is open source? Open source software is software whose code anyone can read, change and share under a licence that allows it. Beginner · Explains an idea · Any system Article Pull requests 15 Oct 2026
Repos in the wild
- GitHub CLI (gh) cli/cli GitHub's official command-line tool. Create and check out pull requests, manage issues, view Actions runs, and sign in to GitHub from the terminal. GitHub
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Commitpedia +2,839 chars