Update: As I presented in "What exactly does Git's "rebase --preserve-merges
" do (and why?)", since Git 2.18 (Q2 2018), you would prefer the new option --rebase-merges
to the legacy one --preserve-merge
Since then:
So:
git rebase --interactive --rebase-merges origin/master
# or
git config pull.rebase merges
git rebase --interactive origin/master (would use rebase-merges)
Original answer 2013:
Or (for the upcoming git 1.8.5 Q4 2013, now delivered in git 1.8.5, 2013-11-27):
"git pull --rebase
" always chose to do the bog-standard flattening rebase.
You can tell it to run "rebase --preserve-merges
" by setting "pull.rebase
" configuration to "preserve
".
So a simple config will be enough to make sure your pull --rebase
does preserve merge:
git config pull.rebase preserve
See commit 66713ef3 for more (thanks to Stephen Haberman):
pull: allow pull to preserve merges when rebasing
If a user is working on master, and has merged in their feature branch, but now has to "git pull
" because master moved, with pull.rebase
their feature branch will be flattened into master.
This is because "git pull
" currently does not know about rebase's preserve merges flag, which would avoid this behavior, as it would instead replay just the merge commit of the feature branch onto the new master, and not replay each individual commit in the feature branch.
Add a --rebase=preserve
option, which will pass along --preserve-merges
to rebase.
Also add 'preserve
' to the allowed values for the pull.rebase
config setting.