5

This is what I normally do when rebasing my current branch whilst keeping my local branching from getting flattened:

git fetch origin
git rebase -r origin/develop

-r is --rebase-merges, which I prefer over --preserve-merges

My question is: is there a way to pass this when doing git pull --rebase ?

Eg - I'd like to run the equivalent of the command above like so:

git pull --rebase=rebasemerges origin develop

instead of:

git pull --rebase=preserve origin develop

**edit: OK - looks like in 2.22, --preserve-merges is getting deprecated in favour of --rebase-merges. This is for git rebase though - fingers crossed the changes gets carried over to git pull --rebase

YS.
  • 1,808
  • 1
  • 19
  • 33
  • Here's a link to the background of my edit: https://stackoverflow.com/a/50555740/857428 – YS. May 16 '19 at 02:59

2 Answers2

7

git 2.22 has been released.

To answer my own question - this is the equivalent command:

git pull --rebase=merges origin develop

Taken from the manual page:

-r --rebase[=false|true|merges|preserve|interactive] When true, rebase the current branch on top of the upstream branch after fetching. If there is a remote-tracking branch corresponding to the upstream branch and the upstream branch was rebased since last fetched, the rebase uses that information to avoid rebasing non-local changes.

When set to merges, rebase using git rebase --rebase-merges so that the local merge commits are included in the rebase (see git-rebase1 for details).

To make this a default pull behaviour:

git config --global pull.rebase merges

YS.
  • 1,808
  • 1
  • 19
  • 33
  • 1
    Good update. Don't forget to pair that config with `rebase.autostash` set to true: https://stackoverflow.com/a/30209750/6309 – VonC Jun 10 '19 at 22:21
1

Yes, as I explained in "What exactly does git's “rebase --preserve-merges” do (and why?)", the old --preserve-merges option will disappear.

And yes, the git pull -r option will be updated accordingly, but that is not yet implemented.
See the patch in preparation here.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250