Gerrit: combine multiple commits into one “change”

前端 未结 3 448
温柔的废话
温柔的废话 2021-01-30 13:30

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 comm

相关标签:
3条回答
  • 2021-01-30 13:30

    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.

    0 讨论(0)
  • 2021-01-30 13:36

    If you need to update already posted review requests then you can leverage amend commits:

    git commit --amend -C HEAD
    

    and then push for consequent review.

    I believe that public commits should be atomic and contain the complete bunch of functionality which you want to contribute. Usually you do not want to share all of your intermediate commits. So squashing commits before review is good idea.

    0 讨论(0)
  • 2021-01-30 13:42

    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.

    0 讨论(0)
提交回复
热议问题