I found that when clicking "Submit Patch Set" in the Gerrit web interface, it'll either simply add a commit to that branch, or create a merge commit if another commit was submitted just before.
Example that creates 2 commit: The actual commit and a merge commit:
There is a "Rebase Change" button which is great but it means that to submit a patch set everyone should always do:
The only reason I see a merge commit useful is to keep dates of the commits (but I do understand why it is required without a rebase).
Isn't there an automatic rebase or at least a check to avoid generating an undesired merge commit?
Rebasing is usually the last step before pushing changes to Gerrit; this allows you to make the necessary Change-Ids. The Change-Ids must be kept the same. squash: mixes two or more commits into a single one. reword: changes the commit message.
But, instead of using a merge commit, rebasing re-writes the project history by creating brand new commits for each commit in the original branch. The major benefit of rebasing is that you get a much cleaner project history. First, it eliminates the unnecessary merge commits required by git merge .
Before rebasinggit rebase rewrites the commit history. It can be harmful to do it in shared branches. It can cause complex and hard to resolve merge conflicts. In these cases, instead of rebasing your branch against the default branch, consider pulling it instead ( git pull origin master ).
Yes. Change the Submit Action for your project(s) to Cherry Pick. This will do roughly the same as rebasing when the submit button is pressed. It will keep the clean history you are looking for with no merge commits when submitting changes.
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