Pull requests are how you ask your team to check your changes before they land in the main branch. They are where most code review happens, and they leave a record of what changed and why.
What a pull request is
A pull request (PR) is a proposal to merge one branch into another, usually a feature branch into main. The name says what you are asking for: you want the people who look after the project to pull your commits into their branch. GitLab calls the same thing a merge request.
The pull request most developers know isn't part of Git. Git gives you branches, commits and merges. Hosting platforms such as GitHub, GitLab, Bitbucket and Azure DevOps build the pull request on top, as a page that holds:
- the diff: every line added, changed or removed, compared with the target branch;
- a title and description saying what changed and why;
- comments, on the whole PR or on single lines of the diff;
- reviews: each reviewer's verdict;
- checks: the results of the tests, linters and builds run against the branch.
Why main stays off limits
main is the branch everyone builds on, and usually the one that gets deployed. A broken commit there breaks things for the whole team at once, so most teams never commit to it directly. Each change starts on its own branch, where it can be as messy as it needs to be until it's ready.
Branches are cheap in Git. A branch is a named pointer to a commit, so making one costs almost nothing. How long branches live and where they merge is a team choice; Branching Strategies compares the common approaches.
How a pull request works
Wondering how this was made? How we make these