Video in progress
What is a pull request (a merge request in GitLab), and why do you not push straight to `main`?
A pull request is a proposal to merge the changes on your branch into the main branch. Before the code goes in, colleagues review it, CI runs the tests, and the discussion stays in one place.
📖 Answer
Git itself has no concept of a PR. It is a layer added by GitHub, GitLab and Bitbucket. The process usually goes like this:
- You create a
feature/sms-notificationbranch frommain. - You commit and push the branch.
- You open a PR: what you did and how you checked it.
- CI runs the build and tests, and reviewers leave comments.
- When everything is green, merge.
If you push straight to main, untested code reaches everyone instantly and may head to prod. That is why many teams protect main: pushing is closed, and only a PR with at least one approval gets in.
Keep PRs small. People write "LGTM" on a 2000-line PR, and they actually read a 200-line one.
Sign up to mark studied questions and save your progress.