Beginner · 6 min read
My first pull request, step by step
From an idea to a merged change: branch, push, open the PR, describe it, get it merged.
What a pull request is
A pull request (merge request on GitLab) asks: “please bring the commits of my branch into main”. It's a page where the team reads the diff, comments, runs the tests, then merges. Nothing touches main before that.
1. A branch from an up-to-date main
Always start from the latest main, otherwise your PR will carry old stuff or conflicts.
$ git switch main$ git pull$ git switch -c feat/dark-mode
2. Commit and push the branch
-u links your local branch to the remote one: next times, git push is enough. Git prints a link to open the PR.
$ git add .$ git commit -m "feat: dark mode toggle"$ git push -u origin HEAD
3. Open it and describe it
Title like a good commit message. In the description: why, what changed, how to test, screenshots for UI. Write “Closes #12” to close the issue on merge. Not finished? Open it as a Draft.
$ gh pr create --fill --draft
4. After the merge
Delete the branch (GitHub offers a button), come back to main and pull. Your change is now in main.
$ git switch main$ git pull$ git branch -d feat/dark-mode