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
'.
git pull
which points to git pull --ff
. But please don't call it git puff
. –
Wattle merge.ff
is taking precedence, but I think what's actually happening is that true
isn't a valid value (the man page doesn't mention true
as a possible value). The invalid value causes the option to become unset, causing fallback to the current merge.ff
behavior. merge.ff
doesn't seem to override pull.ff
because if you set the latter to only
it takes effect just fine. I'm actually somewhat annoyed that true
isn't equivalent to passing --ff
. –
Kop Here's my tentative workflow (Note that the pull.ff
config option only works on git 2.x.).
Use this config:
- Set
merge.ff
tofalse
. This defaults themerge
behavior to--no-ff
. - Set
pull.ff
toonly
. This defaults thepull
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.
© 2022 - 2024 — McMap. All rights reserved.
merge.ff
takes precedence. – Pukka