A pull request is the standard unit of collaboration in a repository: the author proposes a change, the team discusses it line by line, automated tests run, and only after review does the branch reach the main one. On GitHub a change is proposed with a pull request (PR), on GitLab with a merge request (MR); the idea is the same.
How a pull request is structured
A pull request always involves two branches: the source branch (head, also called compare on GitHub) with the proposed commits, and the target branch (base) they are meant to be merged into, usually main. The pull request page gathers everything reviewers need:
- description and discussion: why the change is made, and line-by-line review comments and decisions
- diffs: which files and lines change, before and after
- the branch’s commits and how it changed over time
- status of checks: automated tests, builds and linters from the CI pipeline
A change can be opened as a draft: such a pull request cannot be merged until the author marks it “ready for review”, which is handy for showing work early. A developer outside the team without write access works through a fork: they copy the repository to their own account and open a pull request from the fork into the original project.
Review and branch protection
The reviewer leaves comments on individual lines and gives a decision. The main branch is protected by rules: changes can be merged only through a pull request, with the required number of approvals and passing checks.
| Review decision | Meaning |
|---|---|
| Approve | the changes are approved and can be merged |
| Request changes | there are comments the author must address before merging |
| Comment | comments and questions without an explicit approval or rejection |
Ways to merge changes
Merging is configured at the project level, and it determines what the history of the main branch will look like:
| Method | Result |
|---|---|
| Merge commit | a merge commit is added, so both the changes and the branch boundaries are visible (git merge --no-ff) |
| Fast-forward | no merge commit; possible only while main has not moved ahead (git merge --ff-only) |
| Squash | all the branch’s commits are squashed into one new commit; the original commits stay in the branch |
GitLab also offers an intermediate option, a merge commit with semi-linear history: a merge commit is created only if a fast-forward is possible, otherwise you are asked to rebase the branch first.
Sources
the term is written from these pages- GitHub Docs — About pull requestsdocs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests(opens in a new tab)
- GitHub Docs — Pull request reviewsdocs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/about-pull-request-reviews(opens in a new tab)
- GitLab Docs — Merge methodsdocs.gitlab.com/user/project/merge_requests/methods/(opens in a new tab)
Verified 9 Nov