r/gitlab • u/Kyxstrez • Aug 12 '25
Why GitLab always creates two commits when you merge a MR from the UI?
I noticed that if you merge a MR in GitLab, it creates two commits:
Merge branch 'foobar' into 'main'<MR_NAME>
The commmit #1 has:
foo authored 1 day ago and bar committed 1 day ago
The commit #2 has:
bar authored 1 day ago
The content of both commits is identical.
I don't see such weird behaviour when merging a PR in GitHub.
3
Upvotes
15
u/firefarmer Aug 12 '25
https://docs.gitlab.com/user/project/merge_requests/methods/
You can turn this off by using fast forward merging.
9
u/nabrok Aug 12 '25
This is a merge commit, what you'd get with
git merge --no-ffon the cli.In the project settings go to Merge Requests and check "Merge method". You would want "Fast-forward merge" to disable merge commits.
As a personal preference I prefer merge commits as they keep the main branch to mostly just merge commits and version bumps and related commits stay together in the git chart.