I want git to always make merge commits (--no-ff
) when I use git merge
, but keep the default behavior (--ff
) for git pull
. Is this possible (with configs)?
The two configs which might help are:
merge.ff
(From git merge
man page): When set to false
, this variable tells Git to create an extra merge commit in such a case (equivalent to giving the --no-ff
option from the command line).
pull.ff
(from the git config
man page)
Setting pull.ff
to true
would keep the default behavior where Git does not create an extra merge commit when merging a commit that is a descendant of the current commit.
To be tested: does pull.ff
takes precedence over merge.ff
?
git config pull.ff only
git config merge.ff false
As mentioned by Kelvin's answer and confirmed by git-pull.sh
, 'only
' is the value to use, not 'true
'.
Here's my tentative workflow (Note that the pull.ff
config option only works on git 2.x.).
Use this config:
merge.ff
to false
. This defaults the merge
behavior to --no-ff
.pull.ff
to only
. This defaults the pull
behavior to --ff-only
.That means if you try to pull
a branch where your local is both behind & ahead of the remote, the pull
will fail. In that case, do a rebase
so you're not behind any more.
Note:
I tried setting pull.ff
to true
but git seems to treat it as though the option is entirely unset. Note that the man page doesn't mention that true
is a recognized value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With