As a git best practice, one should commit frequently, but to review the code you may need to review a patch consisting of multiple commits at once. Is there a way multiple commits can be reviewed and either merged or rejected at once?
The default way is to correct it locally (i.e. combine both commits using either git rebase --interactive or git reset --soft HEAD~1; git commit ). Then push the combined commit. Finally, abandon the now obsolete (and marked as OUTDATED) second commit using the gui/website.
To "squash" in Git means to combine multiple commits into one. You can do this at any point in time (by using Git's "Interactive Rebase" feature), though it is most often done when merging branches. Please note that there is no such thing as a stand-alone git squash command.
One thing you can do a squash merge to a temporary branch and then post that change for review.
git checkout -b feature git commit -m "start feature" ... git commit -m "finish feature" git checkout -b feature-review master git merge --squash feature git commit
Now your feature-review
branch will contain the same diff relative to master
as feature
did but with only a single commit.
No, Gerrit does not currently support batching commits into one review. However, there are a couple other options.
At $DAYJOB, my team uses feature branches for larger changes. The smaller commits are reviewed/merged to the feature branch individually, but the feature branch is only merged in once everything is in a good place and all developers are happy.
Gerrit also supports topic branches - which are a convenient way to group related commits. They are discussed briefly in the documentation. These commits must still be reviewed/merged individually, but they can be quickly grouped together in the web UI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With