Reputation: 170
I want to keep the branch information of merged branches, so I have set up branch.master.mergeoptions=--no-ff
. This way, a merge commit is always generated even when it could be fast-forwarded.
A side effect however, is that a merge commit is created when doing a git pull
(more specifically: Update in IntelliJ or Eclipse). To prevent a log full of Merge remote-tracking branch 'origin/master'
, I also set branch.master.rebase=true
which will fast-forward the master
to origin/master
when pulling it.
This setup has another side effect: when I merge a branch to master
and after that I git pull
because I forgot to do that before the merge, my branch information is lost: the feature branch is flattened in master
.
The command git pull --rebase=preserve
is exactly what I need: it will rebase master
, then apply the merge of the branch again. But I need this to be done automatically, since most of these commands are executed by Eclipse or Intellij. I want git pull
actually perform a git pull --rebase=preserve
There's a config setting pull.rebase=preserve
which should do just that, but even after I set this config, git pull
will do just a git pull --rebase
and not the expected git pull --rebase=preserve
, while I'm currently using git version 2.12.2 which is expected to contain that feature.
So how can I make sure that when I do a git pull
on my master, that it will preserve my merge commits even when I didn't update my master before the merge?
Upvotes: 2
Views: 491
Reputation: 170
The setting branch.master.rebase=true
is actually overriding the default pull.rebase=preserve
.
The solution is to execute the command
git config branch.master.rebase merges
so that the config setting is now branch.master.rebase=merges
. This will preserve the merge commits automatically when doing a git pull
Upvotes: 2