Git Pull Request Workflow

With tools like Github, Gitlab, and Gitea, pull request (PR) workflow is often recommended. This is how I do it:

  • git checkout -b cbrake/main
  • make changes
  • git add/commit
  • git push -u origin HEAD

(substitute your user name and target branch)

When you push your branch, Gitlab and Gitea will give you nice links to click on to open a PR.

Why use PRs instead of committing directly to main?

  • it groups your commits for better organization (a feature can be a one PR)
  • provides email notifications to the rest of the team on activity
  • provides an opportunity to review and discuss the changes

Most Git repos I work on are configured to block commits directly to the main branch forcing everything to go through PRs. Even for solo development, PRs (like Git itself) are a useful tool to organize your work.

Is it common to use PRs?
In every role I’ve had it has always been “just merge your feature branch to the dev branch when you are done, no PR required”

I use PRs all projects – even those where I am the only contributor. I think the benefits outweigh the overhead.