2

The merge request page on gitlab is suggesting to use 'git merge --no-ff'.

I am looking for best practices on when to use --no-ff, but I am having difficulty to find a good explanations on the best-practices aspect. The git merge tutorials I found do not mention --no-ff.

Any suggestions?

JBentley
  • 6,099
  • 5
  • 37
  • 72
Gui Lima
  • 166
  • 1
  • 9
  • 3
    I belive this question will help you: http://stackoverflow.com/questions/18126297/when-to-use-the-no-ff-merge-option-in-git – Seb Dec 03 '15 at 16:13
  • 3
    Duplicate of [What is the difference between `git merge` and `git merge --no-ff`?](http://stackoverflow.com/questions/9069061/what-is-the-difference-between-git-merge-and-git-merge-no-ff) – Uday Shankar Dec 03 '15 at 16:13
  • 1
    Take a look to the following explanation, it might help: http://nvie.com/posts/a-successful-git-branching-model/#incorporating-a-finished-feature-on-develop – Яois Dec 03 '15 at 16:19

2 Answers2

2

The use of --no-ff on merge is how GitLab and GitHub do their merges for pull requests / merge requests. This gives you a single commit sha that can be reverted to revert a PR/MR. See: https://git-scm.com/blog/2010/03/02/undoing-merges.html (the last paragraph also points out using --no-ff)

Essentially, best practice is to use them when merging feature branches, merge requests, pull requests. When merging codelines, say merging master into a release line, or pulling a patch line back down into master, you would probably not bother with --no-ff and let it be fast-forward if it can.

twk3
  • 1,848
  • 13
  • 7
1

According to the documentation --no-ff:

Create a merge commit even when the merge resolves as a fast-forward. This is the default behaviour when merging an annotated (and possibly signed) tag.

There is a list of all of the commands at:

https://git-scm.com/docs/git-merge

This was also answered at:

What is the difference between `git merge` and `git merge --no-ff`?

Community
  • 1
  • 1
NendoTaka
  • 1,224
  • 8
  • 14
  • Yes, I read the documentation, but I am asking about the best-practices aspects. This is not clear from the documentation. – Gui Lima Dec 03 '15 at 16:13
  • @GuiLima Your title question asked what the purpose of it was, which is probably what mislead this answerer (and also some of the comment writers). I changed your title to match the body of your question. – JBentley Dec 03 '15 at 16:21