At work we use gerrit for codereview and as a git server. Also we have the following workflow:
- For each feature create a new feature branch
- If feature is ready, push it to
git push origin HEAD:refs/for/feature
for codereview - After codereview, submit your change and merge origin/feature in your local master:
git checkout master && git merge --no-ff origin/feature
- After resolving all conflicts push it a second time to gerrit
git push origin HEAD:refs/for/master
- If the change from step 4 is okay, submit it.
Problem: Lets say everything works smooth until step 5. My change was reviewed and I´m ready to submit the change. In the meantime another developer pushes some changes directly to master. Gerrit gives me now a "merge conflict" in my change without the option to submit my change.
Now i´m a little bit lost in how I should resolve this issue...at the moment I can only come up with the following three solutions:
- Checkout the change and
git rebase origin/master
(losing my previous merge commit, rewriting history) - Checkout the change and
git rebase --rebase-merges origin/master
(rewriting history) - Checkout the change and 'git merge --no-ff origin/master' (history is a little bit f*cked up...)
Is there a safe and elegen solution to this problem ? How would you solve it ? I´m quite new to git/gerrit and dont want to mess up our repo...