I use GitLab in my project. I\'m exploring Merge Requests feature.
topic_branch
from master
.I should have created a squash of commits on branch
With GitLab 13.3 (August 2020), there is a new option which is interesting in your case:
Squash Commits Options
Squashing commits in Git is a great way to combine several commits into a single one.
It’s great for grouping several commits, which by themselves may provide little historical value, into a single large commit before pushing upstream.
Pushing a single commit allows for a more meaningful commit message, as well as ensuring the group of commits provides a “green” continuous integration pipeline.In GitLab 13.3 we are adding configurable defaults for squashing commits, allowing project maintainers to configure the option to suit their preferred workflow.
Because changing squash configuration may introduce unwanted behavior, configuration has not been changed for new or existing projects. With 314 upvotes
update currently gitlab supports both rejecting non-fast-forward commits and squashing multiple commits of a merge request, so my comment below isn't that valid anymore
original content
If you don't want to have a merge commit, don't do a merge. That means do a rebase on target branch (master) and a push.
As I understood from http://doc.gitlab.com/ee/workflow/rebase_before_merge.html GitLab will always create merge commit to keep a way to revert the whole branch.
Your Project > Settings > General > Merge Request Settings > Fast-Forward Merge.
Personally, I also prefer to do squash commits
on every merge.
I think GitLab supports this now.
project
settings
(Note: This is NOT the profile settings available on the top right)General
tab.Merge Request Settings
sectionFast-Forward Merge
.
- checkout
master
- merge
topic_branch
intomaster
- commit / push
master
In this case, there would be only 1 commit onmaster
.
That is not true. You will have all the commits from topic_branch
and a Merge branch 'topic_branch'
commit in your master, except the case that no commits were added to your master branch since you branched off topic_branch
. In this case, the default behaviour of git merge
is to perform a fast forward merge. A fast forward merge merges your topic_branch
es changes to master without a merge commit (see here for further documentation).
However, when you create a merge request in GitLab, as the name says, you are requesting to merge your topic_branch
into your code base. Per default, GitLab will always create a merge request, even if a fast forward merge is possible, to preserve the fact that the commits were developed on another branch in your history.
Now the good news: you can configure GitLab to perform fast-forward merges instead of creating merge commits: see here. It seems, however, that this is only possible in GitLab Enterprise Edition.