Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 405
YS. Avatar asked May 16 '19 02:05

YS.


1 Answers

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

like image 104
YS. Avatar answered Oct 18 '22 06:10

YS.