You’ve passed all the way of flames, blood and pain, through Gerrit, you done reviewing a change and you’re ready to click
Review and Publish button. You hit it and Gerrit hits you with:
Project policy requires all submissions to be a fast-forward. Please rebase the change locally and upload again for review. How, the hell this happend and how to handle this?
Why does this happens, and how to handle this, is explained in details in this Google Groups thread. You can follow this link, if you don’t like Google Groups (filled with slowly working AJAX and nasty formating) and would prefere a little bit closer to plain-text answer. I’m putting most important details below, stripping all unnecessary blah, blah.
In general, this happens, when the same file is modified by two different changes / in two different branches. Gerrit cannot merge file contents during change submit. So only one change can be submitted at once. The other will require the user to rebase the change before Gerrit can submit it.
Steps to resolve this situation:
- Push first change / branch. Review and submit it in Gerrit.
- Checkout master and pull the latest repository (
- Checkout the next change / branch.
- Rebase its contents onto current repository state (
git rebase origin/master).
- Push replacement upload (in most cases use standard
git push) and review the change again in Gerrit UI.
If you have your Git+Gerrit environment properly configured (you’re sending proper refs with each pull and you add unique Commit-Id to each commit), last point is just a simple
git push. If any of mentioned isn’t right at your system, for example your commits doesn’t have Change-ID, you must eithere add them manually, tell Gerrit for which change you’re sending a rebased patch set or even use manual replacement mapping technique. Details can be found in Gerrit docs.
That’s all folks. BTW! There are some reports that you can use the very same solution to solve similar problem, that comes from the fact, that Gerrit doesn’t support recursive merge strategy (only resolve merge strategy). So, if your change depends on another (possibly already merged), but contains changes to files that would require recursive merge, Gerrit will reject such change. Using
git rebase origin/master to rebase (and merge) change locally and then submitting it to Gerrit is reported to help in this case.