Last Updated: January 17, 2018
· sickill

Rebase by default when doing git pull


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


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

over 1 year ago ·

ready4god2513: here's a nice write-up on the topic:

over 1 year ago ·

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

over 1 year ago ·

There's another reason to always do rebasing pulls --- to avoid foxtrot merges!

over 1 year ago ·