问题
We (git/gerrit newbs) are trying to use gerrit with feature branches. The workflow we are trying to implement is as follows:
- User creates a feature branch, pushes it to the remote repo directly (no review) with
git push -u origin users-branch
. - As changes pile up in the master branch, user does
git pull --rebase origin master
(--rebase
is needed because otherwise git creates a merge commit, and merge commits cannot be pushed through gerrit). - User continues to push his changes to the remote repo with
git push --force origin users-branch
(--force
is needed because of--rebase
at the previous stage; I'm looking for a better way to do this). - Other users can contribute to the feature branch by pushing their own changes.
- When the feature is ready, the user pushes it for review with
git push origin HEAD:refs/for/master
.
The last step doesn't work because commits that were pushed to gerrit at any stage cannot be pushed again.
The gerrit manual suggests to amend the commits you want to push again. This seems complicated and error prone.
It all works if user never pushes his changes to remote repo, because gerrit doesn't see the changes until they are pushed for review. But this is exactly what we don't like.
It seems possible to use a different repo for feature branches, such that gerrit never sees duplicate change IDs, but this again seems like a needless complication.
Is there a way to do what we want safely and elegantly?
回答1:
If you're running at least Gerrit 2.11 you can benefit from the fix for issue 1195 and enable the create-new-change-for-all-not-in-target
option to take into account target branch when determining new changes to open.
回答2:
You are trying to work on Gerrit with a pull-request workflow (Like Github, Bitbucket, ...).
We just created a Gerrit client tool to do that:
https://github.com/Cosium/vet
With vet
, you can have feature branches and you can add any number of commits without amending or rebasing the feature branch.
来源:https://stackoverflow.com/questions/37390823/gerrit-with-tracked-feature-branches