At work we use gerrit for codereview and as a git server. Also we have the following workflow:
git push origin HEAD:refs/for/feature
for codereviewgit checkout master && git merge --no-ff origin/feature
git push origin HEAD:refs/for/master
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´ma little bit lost in how I should resolve this issue...at the moment I can only come up with the following three solutions:
git rebase origin/master
(losing my previous merge commit, rewriting history)git rebase --rebase-merges origin/master
(rewriting history)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...
I'd recommend a workflow that relies on rebasing. That is, your solution 1.
I would also recommend periodically rebasing to HEAD between steps 1 and 2 during development to minimize surprises at review time.
Generally this makes it easier to understand the change as a simple application of your commits. I find it is generally much easier from the perspective of the reviewer too, and also for everyone to reason about should there ever be a need to roll back a change.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.