tnoiug
Last Updated: January 17, 2018
·
100.5K
· sickill

Rebase by default when doing git pull

git

If you want git to do a rebase instead of a merge when pulling you can run git pull like this:

git pull --rebase

Instead of typing the above (or making an alias for it), you can tell git to automatically rebase when pulling.

In git >= 1.7.9:

git config --global pull.rebase true

In git < 1.7.9:

git config --global branch.autosetuprebase always

The latter has the effect of automatically adding branch.<name>.rebase true for each checked out local branch that is tracking an upstream branch to the repository config file.

Note that if you have both options set (not really recommended) then branch.<name>.rebase true that is automatically added for each branch takes precedence over global pull.rebase true.

4 Responses
Add your response

6059

Would you mind explaining the benefit of the rebase? Just to keep the commit log cleaner?

over 1 year ago ·
6064

ready4god2513: here's a nice write-up on the topic: http://mislav.uniqpath.com/2013/02/merge-vs-rebase/

over 1 year ago ·
26480

Hmm, why --global? You might not want to let this affect your work in all repos.

over 1 year ago ·
27802

There's another reason to always do rebasing pulls --- to avoid foxtrot merges! http://bit-booster.blogspot.ca/2016/02/no-foxtrots-allowed.html

over 1 year ago ·