Is there a way to setup the host Git repository such that any git pull done from its (local) clones uses --rebase by default? By searching on Stack Overflow, I learned about branch.autosetuprebase, but it needs to be configured per clone individually.
My project flow is set up such that we pull the develop branch before mergeing a feature branch to it. This pull nearly always uses --rebase, so I am trying to figure out if this can be the default.
There are now 3 different levels of configuration for default pull behaviour. From most general to most fine grained they are:
1.
pull.rebaseSetting this to
truemeans thatgit pullis always equivalent togit pull --rebase(unlessbranch.<branchname>.rebaseis explicitly set tofalse). This can also be set per repository or globally.2.
branch.autosetuprebaseSetting this to
alwaysmeans that whenever a tracking branch is created, a configuration entry like the one below will be created for it. For finer grained control, this can also be set tonever,localorremoteand can be set per repository or globally. Seegit config --helpfor further details.3.
branch.<branchname>.rebaseSetting this to
truemeans that that particular branch will always pull from its upstream via rebasing, unlessgit pull --no-rebaseis used explicitly.Conclusion
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.