Each merge request increments 'x commits behind master'


I am new to Git and Gitlab and I have a question about something I do not understand, and have not found an answer to on Google or in this forum.

I have two branches, ‘dev’ and ‘master’. I develop in ‘dev’. And every time I create a merge request, I see the message ‘The source branch is x commits behind the target branch’.

Below the green ‘Merge’-button, there is a message saying ‘1 commit and 1 merge commit will be added to master’.

When I then merge ‘dev’ into ‘master’, the ‘x commits behind the target’ is incremented. Probably because of the merge-commits that are added.

Since both ‘dev’ and ‘master’ are always the same after the merge, where does this count come from and how can I get rid of cq. resolve it?

Thanks for any info!

- -

Hi @MrMacvos
you get it, because when you merge dev into master by default you create a merge commit which is not in the dev branch history.
In order to get it resolved you can disable merge commits in your Project → Settings → General → Merge requests → Merge method and select Fast-forward merge.

With this setup you will need to do some extra steps in case of conflicts, but if you don’t commit/push directly to master it shouldn’t be a problem.

Hi @balonik

Thanks for the answer. I have read more about fast-forward merge and ended up reading about rebasing… I think fast-forward merges are fine in my situation. I’ll give it a try!


- -