We are planning to use Git pull requests for code review in our company. Before we start I have a basic question: How often should I open a pull request? Is it best to open one for every little commit I create? Or should I open a single pull request for a larger quantum of work, such as all the commits in, say, a user story? What is the right size?
What do you do in your team?
1
open a single pull request for a larger quantum of work, such as […] a user story?
That’s what you should do.
Two reasons:
-
There is a mantra that one should “commit early and often”. Once you get used to it, you will recognize that this is a good habit. The side effect of it is, that you will produce a larger number of commits, which you may or may not want to squash later into fewer ones. That’s perfectly ok as long as you didn’t publish the stuff in any way.
-
Once you’re finished with your work and want it to be merged, you open a PR. Keep in mind that the people who are acting upon your PR are not interested in every single minorish step of the development. They want a completed feature as a whole, because they will have to review it.
One major point about DVCS is exactly that: There is no need to publish every tiny step, but you still have the benefits of a repository. Once the branch is merged into the main development branch and/or repository you are contributing to via PRs, typically only the end result is of interest.