tl;dr How can I update a gitlab merge request the same way as a gerrit changeset?
In a rather standard gitlab setting, I own a project and want it to keep a linear history. I set the merge settings accordingly and everything works fine from the UI.
If I want to incorporate feedback into an existing merge request, I am currently forced to git push --force
my branch which I find both inconvenient and dangerous. As a counterexample, gerrit has a special target refs/for/XXX
where I can push my changes. Gerrit then identifies the changeset by an Id in the commit message and happily creates a new version of the changeset.
Is there a similar feature for gitlab? Can I push my (rebased, squashed, ammended) changeset somewhere so that it automatically becomes a new version of an existing MR?
Force push is a valid workflow in this case. It is not that dangerous, because the old version of the branch is still available locally via git reflog
and on the server all the versions you pushed are also saved in gitlab (see https://docs.gitlab.com/ee/user/project/merge_requests/versions.html).
You can push modifications happening during the review in new commits and once the branch is ready to be merged use gitlab's squash commits functionality if you really want to avoid force pushing, but this offers less flexibility than using interactive rebase with force push, because it means that the whole branch will be turned into a single commit before being merged.
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