Masked Man Masked Man - 1 year ago 77
Git Question

How to make Git pull use rebase by default for all my repositories?

Is there a way to setup the host Git repository such that any

git pull
done from its (local) clones uses
by default? By searching on StackOverflow, I learned about
, but it needs to be configured per clone individually.

My project flow is set up such that we
branch before
ing a feature branch to it.This
nearly always uses
, so I am trying to figure out if this can be the default.

(Edit Restructured the question according to discussion below with Jonas Wielicki.)

Answer Source

There are now 3 different levels of configuration for default pull behaviour. From most fine grained to most general, they are:

1. branch.<branchname>.rebase

Setting this to true means that that particular branch will always pull from its upstream via rebasing, unless git pull --merge is used explicitly.

2. branch.autosetuprebase

Setting this to always means that whenever a tracking branch is created, a configuration entry like the one above will be created for it. For finer grained control, this can also be set to never, local or remote and can be set per repository or globally. See git config --help for further details.

3. pull.rebase

Setting this to true means that git pull is always equivalent to git pull --rebase (unless branch.<branchname>.rebase is explicitly set to false). This can also be set per repository or globally.


So while you can't change the default behaviour for all future clones of a repository, you can change the default for all of the current user's (existing and future) repositories via git config --global pull.rebase true.