Gerrit: combine multiple commits into one “change”

醉酒当歌 提交于 2019-12-02 17:16:58
Brad

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.

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.

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!