A Successful Git Branching Model recommends to use --no-ff
when merging branches:
The
--no-ff
flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature. […]Yes, it will create a few more (empty) commit objects, but the gain is much bigger that that cost. Unfortunately, I have not found a way to make
--no-ff
the default behavior of git merge yet, but it really should be.
Understanding the Git Workflow, however, recommends not to use --no-ff
:
So you add a new rule: “When you merge in your feature branch, use
–-no-ff
to force a new commit.” This gets the job done, and you move on. […]The
--no-ff
band-aid, brokenbisect
, andblame
mysteries are all symptoms that you’re using a screwdriver as a hammer. […]
Both approaches seem reasonable for difference scenarios, but what is considered "good practice?"
When do you use --no-ff
, when do you not, why?
git rebase
, but the final merge is done with--no-ff
. – Statutable--no-ff
ongit merge -h
(git version 2.7.4) – Further