Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab merge request with --no-ff

Tags:

gitlab

Does Gitlab support merge request with --no-ff?

I found in Gitlab, it only supports fast-forward mode. While in Github, we're provided with 2 options: To merge or squash (--no-ff).

I'd like to discard verbose commit messages in Gitlab master branch on approving a merge request. That's why I wish there's squash option in Gitlab.

like image 983
sancho21 Avatar asked Aug 01 '16 07:08

sancho21


2 Answers

You can configure the merge method in the repo settings. Available options are:

Merge commit

A merge commit is created for every merge, and merging is allowed as long as there are no conflicts.

Merge commit with semi-linear history

A merge commit is created for every merge, but merging is only allowed if fast-forward merge is possible. This way you could make sure that if this merge request would build, after merging to target branch it would also build. When fast-forward merge is not possible, the user is given the option to rebase.

Fast-forward merge

No merge commits are created and all merges are fast-forwarded, which means that merging is only allowed if the branch could be fast-forwarded. When fast-forward merge is not possible, the user is given the option to rebase.

This is also available on self-hosted GitLab Community Edition.

like image 64
agilob Avatar answered Jan 03 '23 22:01

agilob


Squashing is not really related to --no-ff (no fast forward)

If all you want to do is remove noise commit messages. You want to squash your commits. If you want to remove merge commits you fast forward (achieved by doing a rebase).

To squash, you can do this through command line with

git rebase -i HEAD~[NUMBER OF COMMITS]

or

git reset --soft HEAD~3 git commit -m "New message for the combined commit"

(There are other ways to achieve this as well)

There is also an option on gitlab to squash your commits for you on merge. It uses the title of the merge request as the commit message.

An example

You open a merge request with the Title

"WAR-132: Display confirmation dialogue when document uploaded"

This merge request contains three commits

WAR-132: Make code more concise.
War-132: Add missing specs (and reorder, reformat of tests)
WAR-132: Display a confirmation dialogue when the document is uploaded

By ticking the squash commits option (found next to the merge button).

An image showing the squash commits option on a merge request

You will end up with the following commit being added to the branch you are merging to.

WAR-132: Display confirmation dialogue when document uploaded
like image 24
Louis Avatar answered Jan 03 '23 23:01

Louis