gitrebasegit-pull

git pull --rebase: passing --rebase-merges


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

Is there a way to pass this when doing git pull --rebase?

For example, 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

OK, it 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.


Solution

  • 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