A pull request asks others to review your branch and merge it into another one. It is a feature of hosting services such as GitHub, Gitea and GitLab (which calls it a merge request), not a core Git command. Git does have git request-pull, but it only prints a text summary that you send yourself.
The usual flow
Start from an up to date main branch and create a branch for one piece of work:
$ git switch main
$ git pull
$ git switch -c fix-typoEdit, then commit and push the branch:
$ git add README.md
$ git commit -m "Fix typo in install steps"
$ git push -u origin fix-typoMany services print a link for opening a pull request in the push output. You can also open one on the website. Choose the base branch (where the work should go, such as main) and the compare or source branch (fix-typo). Button and field names differ between services.
If you cannot push to the project, you usually fork it first. A fork is your own server-side copy. You push to the fork and open the pull request against the original project.
Write it for the reviewer
Give a clear title and say what changed, why, and how you tested it. Small, focused requests are much easier to review than large mixed ones. Check the changes yourself before asking others:
$ git diff main...fix-typoThe three dots show what the branch changed since it split from main.
Respond to review
If a reviewer asks for changes, commit them on the same branch and push:
$ git commit -am "Apply review comments"
$ git pushThe open pull request updates automatically. You do not need a new one.
Merge and tidy up
Once approved, someone with permission merges it. Services often offer a merge commit, a squash (all changes combined into one commit) or a rebase. Projects choose which to allow.
Afterwards, update your local copy:
$ git switch main
$ git pull
$ git branch -d fix-typogit branch -d checks a pushed branch against its upstream, here origin/fix-typo. If that remote-tracking name is already gone, Git may say after a squash or rebase merge that the branch is not fully merged, because the commit hashes differ. Confirm the work is in main before using -D.
Try it
In a practice project you own on any hosting service, push a branch with a one-line change, open a pull request, push a second commit and watch it appear, then merge it.
Check your understanding
Pull Requests
All 3 sections · no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.